Add scaffolding

This commit is contained in:
cora 2022-06-06 15:56:16 +02:00
parent 6c89c8f675
commit 2d8498545c
5 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,73 @@
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
minetest.register_node("mcl_scaffolding:scaffolding", {
description = S("Scaffolding"),
--_doc_items_longdesc = doc.sub.items.temp.build,
--_doc_items_hidden = false,
tiles = {"mcl_scaffolding_scaffolding_top.png","mcl_scaffolding_scaffolding_side.png","mcl_scaffolding_scaffolding_bottom.png"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
walkable = false,
climbable = true,
groups = { handy=1, axey=1, flammable=3, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20, falling_node = 1 },
sounds = mcl_sounds.node_sound_wood_defaults(),
_mcl_blast_resistance = 3,
_mcl_hardness = 2,
on_rightclick = function(pos, node, player, itemstack, ptd)
end,
on_place = function(itemstack, placer, ptd)
local ctrl = placer:get_player_control()
if ctrl and ctrl.sneak then
local pp2 = minetest.get_node(ptd.under).param2
local np2 = pp2 + 1
if minetest.get_node(vector.offset(ptd.above,0,-1,0)).name == "air" then
minetest.set_node(ptd.above,{name = "mcl_scaffolding:scaffolding",param2 = np2})
itemstack:take_item(1)
end
if np2 > 4 then
minetest.check_single_for_falling(ptd.above)
end
return itemstack
end
local node = minetest.get_node(ptd.under)
if itemstack:get_name() ~= node.name then
minetest.set_node(ptd.above,{name = "mcl_scaffolding:scaffolding",param2 = 0})
itemstack:take_item(1)
return itemstack
end
local h = 0
local pos = ptd.under
repeat
pos.y = pos.y + 1
h = h + 1
local cn = minetest.get_node(pos)
if cn.name == "air" then
minetest.set_node(pos, node)
itemstack:take_item(1)
placer:set_wielded_item(itemstack)
end
until cn.name ~= node.name or h >= 32
return
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local apos = vector.offset(pos,0,1,0)
if oldnode.name == minetest.get_node(apos).name then
minetest.check_for_falling(apos)
end
end,
})

View File

@ -0,0 +1,3 @@
name = mcl_scaffolding
author = cora
depends = mcl_sounds

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B