Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
minetest_game
Commits
0636d574
Commit
0636d574
authored
12 years ago
by
PilzAdam
Browse files
Options
Downloads
Patches
Plain Diff
Add upside down slabs and stairs
parent
c4f2bee9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/stairs/init.lua
+96
-0
96 additions, 0 deletions
mods/stairs/init.lua
with
96 additions
and
0 deletions
mods/stairs/init.lua
+
96
−
0
View file @
0636d574
...
...
@@ -21,6 +21,43 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
{
-
0
.
5
,
0
,
0
,
0
.
5
,
0
.
5
,
0
.
5
},
},
},
on_place
=
function
(
itemstack
,
placer
,
pointed_thing
)
if
pointed_thing
.
type
~=
"node"
then
return
itemstack
end
local
p0
=
pointed_thing
.
under
local
p1
=
pointed_thing
.
above
if
p0
.
y
-
1
==
p1
.
y
then
local
fakestack
=
ItemStack
(
"stairs:stair_"
..
subname
..
"upside_down"
)
local
ret
=
minetest
.
item_place
(
fakestack
,
placer
,
pointed_thing
)
if
ret
:
is_empty
()
then
itemstack
:
take_item
()
return
itemstack
end
end
-- Otherwise place regularly
return
minetest
.
item_place
(
itemstack
,
placer
,
pointed_thing
)
end
,
})
minetest
.
register_node
(
"stairs:stair_"
..
subname
..
"upside_down"
,
{
drop
=
"stairs:stair_"
..
subname
,
drawtype
=
"nodebox"
,
tiles
=
images
,
paramtype
=
"light"
,
paramtype2
=
"facedir"
,
is_ground_content
=
true
,
groups
=
groups
,
sounds
=
sounds
,
node_box
=
{
type
=
"fixed"
,
fixed
=
{
{
-
0
.
5
,
0
,
-
0
.
5
,
0
.
5
,
0
.
5
,
0
.
5
},
{
-
0
.
5
,
-
0
.
5
,
0
,
0
.
5
,
0
,
0
.
5
},
},
},
})
minetest
.
register_craft
({
...
...
@@ -95,10 +132,69 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
return
itemstack
end
-- Upside down slabs
if
p0
.
y
-
1
==
p1
.
y
then
-- Turn into full block if pointing at a existing slab
if
n0
.
name
==
"stairs:slab_"
..
subname
..
"upside_down"
then
-- Remove the slab at the position of the slab
minetest
.
env
:
remove_node
(
p0
)
-- Make a fake stack of a single item and try to place it
local
fakestack
=
ItemStack
(
recipeitem
)
pointed_thing
.
above
=
p0
fakestack
=
minetest
.
item_place
(
fakestack
,
placer
,
pointed_thing
)
-- If the item was taken from the fake stack, decrement original
if
not
fakestack
or
fakestack
:
is_empty
()
then
itemstack
:
take_item
(
1
)
-- Else put old node back
else
minetest
.
env
:
set_node
(
p0
,
n0
)
end
return
itemstack
end
-- Place upside down slab
local
fakestack
=
ItemStack
(
"stairs:slab_"
..
subname
..
"upside_down"
)
local
ret
=
minetest
.
item_place
(
fakestack
,
placer
,
pointed_thing
)
if
ret
:
is_empty
()
then
itemstack
:
take_item
()
return
itemstack
end
end
-- If pointing at the side of a upside down slab
if
n0
.
name
==
"stairs:slab_"
..
subname
..
"upside_down"
and
p0
.
y
+
1
~=
p1
.
y
then
-- Place upside down slab
local
fakestack
=
ItemStack
(
"stairs:slab_"
..
subname
..
"upside_down"
)
local
ret
=
minetest
.
item_place
(
fakestack
,
placer
,
pointed_thing
)
if
ret
:
is_empty
()
then
itemstack
:
take_item
()
return
itemstack
end
end
-- Otherwise place regularly
return
minetest
.
item_place
(
itemstack
,
placer
,
pointed_thing
)
end
,
})
minetest
.
register_node
(
"stairs:slab_"
..
subname
..
"upside_down"
,
{
drop
=
"stairs:slab_"
..
subname
,
drawtype
=
"nodebox"
,
tiles
=
images
,
paramtype
=
"light"
,
is_ground_content
=
true
,
groups
=
groups
,
sounds
=
sounds
,
node_box
=
{
type
=
"fixed"
,
fixed
=
{
-
0
.
5
,
0
,
-
0
.
5
,
0
.
5
,
0
.
5
,
0
.
5
},
},
selection_box
=
{
type
=
"fixed"
,
fixed
=
{
-
0
.
5
,
0
,
-
0
.
5
,
0
.
5
,
0
.
5
,
0
.
5
},
},
})
minetest
.
register_craft
({
output
=
'stairs:slab_'
..
subname
..
' 3'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment