commit 03a2039319744adc4c4f487de386b2973bdf48d0 Author: Infinatum Date: Fri Feb 20 14:55:03 2015 +0000 Scaffolding mod diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/functions.lua b/functions.lua new file mode 100644 index 0000000..402514e --- /dev/null +++ b/functions.lua @@ -0,0 +1,89 @@ +scaffolding_nodenames={"scaffolding:scaffolding"} + +minetest.register_on_dignode(function(pos, node) + local i=1 + while scaffolding_nodenames[i]~=nil do + if node.name==scaffolding_nodenames[i] then + np={x=pos.x, y=pos.y+1, z=pos.z} + while minetest.env:get_node(np).name==scaffolding_nodenames[i] do + minetest.env:remove_node(np) + minetest.env:add_item(np, scaffolding_nodenames[i]) + np={x=np.x, y=np.y+1, z=np.z} + end + end + i=i+1 + end +end) + +iron_scaffolding_nodenames={"scaffolding:iron_scaffolding"} + +minetest.register_on_dignode(function(pos, node) + local i=1 + while iron_scaffolding_nodenames[i]~=nil do + if node.name==iron_scaffolding_nodenames[i] then + np={x=pos.x, y=pos.y, z=pos.z+1} + while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do + minetest.env:remove_node(np) + minetest.env:add_item(np, iron_scaffolding_nodenames[i]) + np={x=np.x, y=np.y, z=np.z+1} + end + end + i=i+1 + end +end) + +minetest.register_on_dignode(function(pos, node) + local i=1 + while iron_scaffolding_nodenames[i]~=nil do + if node.name==iron_scaffolding_nodenames[i] then + np={x=pos.x, y=pos.y, z=pos.z-1} + while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do + minetest.env:remove_node(np) + minetest.env:add_item(np, iron_scaffolding_nodenames[i]) + np={x=np.x, y=np.y, z=np.z-1} + end + end + i=i-1 + end +end) + +minetest.register_on_dignode(function(pos, node) + local i=1 + while iron_scaffolding_nodenames[i]~=nil do + if node.name==iron_scaffolding_nodenames[i] then + np={x=pos.x+1, y=pos.y, z=pos.z} + while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do + minetest.env:remove_node(np) + minetest.env:add_item(np, iron_scaffolding_nodenames[i]) + np={x=np.x+1, y=np.y, z=np.z} + end + end + i=i+1 + end +end) + +minetest.register_on_dignode(function(pos, node) + local i=1 + while iron_scaffolding_nodenames[i]~=nil do + if node.name==iron_scaffolding_nodenames[i] then + np={x=pos.x-1, y=pos.y, z=pos.z} + while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do + minetest.env:remove_node(np) + minetest.env:add_item(np, iron_scaffolding_nodenames[i]) + np={x=np.x-1, y=np.y, z=np.z} + end + end + i=i-1 + end +end) + +-- falling nodes go into pocket -- + +function default.dig_hor(pos, node, digger) + if digger == nil then return end + local np = {x = pos.x, y = pos.y, z = pos.z + 1,} + local nn = minetest.get_node(np) + if nn.name == node.name then + minetest.node_dig(np, nn, digger) + end +end diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3d8533a --- /dev/null +++ b/init.lua @@ -0,0 +1,79 @@ +print("scaffolding: Loading 'functions.lua'") +dofile(minetest.get_modpath("scaffolding").."/functions.lua") + +minetest.register_node("scaffolding:scaffolding", { + description = "Wooden Scaffolding", + drawtype = "nodebox", + tiles = {"scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding_top.png", "scaffolding_wooden_scaffolding.png", + "scaffolding_wooden_scaffolding.png", "scaffolding_wooden_scaffolding.png", "scaffolding_wooden_scaffolding.png"}, + paramtype = "light", + paramtype2 = "facedir", + climbable = true, + walkable = false, + is_ground_content = true, + groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3}, + sounds = default.node_sound_wood_defaults(), + 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}, + }, + }, + after_dig_node = function(pos, node, metadata, digger) + default.dig_up(pos, node, digger) + end, + }) + +minetest.register_node("scaffolding:iron_scaffolding", { + description = "Iron Scaffolding", + drawtype = "nodebox", + tiles = {"scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding_top.png", "scaffolding_iron_scaffolding.png", + "scaffolding_iron_scaffolding.png", "scaffolding_iron_scaffolding.png", "scaffolding_iron_scaffolding.png"}, + paramtype = "light", + paramtype2 = "facedir", + climbable = true, + walkable = true, + is_ground_content = true, + groups = {snappy=2,cracky=3}, + sounds = default.node_sound_wood_defaults(), + 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}, + }, + }, + after_dig_node = function(pos, node, metadata, digger) + default.dig_hor(pos, node, digger) + end, + }) + +minetest.register_craft({ + output = 'scaffolding:scaffolding 6', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:stick', '', 'default:stick'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + +minetest.register_craft({ + output = 'scaffolding:iron_scaffolding 6', + recipe = { + {'default:wood', 'default:wood', 'default:wood'}, + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'default:wood', 'default:wood', 'default:wood'}, + } +}) + diff --git a/textures/scaffolding_iron_scaffolding.png b/textures/scaffolding_iron_scaffolding.png new file mode 100644 index 0000000..0eba468 Binary files /dev/null and b/textures/scaffolding_iron_scaffolding.png differ diff --git a/textures/scaffolding_iron_scaffolding_top.png b/textures/scaffolding_iron_scaffolding_top.png new file mode 100644 index 0000000..86e7c1c Binary files /dev/null and b/textures/scaffolding_iron_scaffolding_top.png differ diff --git a/textures/scaffolding_wooden_scaffolding.png b/textures/scaffolding_wooden_scaffolding.png new file mode 100644 index 0000000..d986f71 Binary files /dev/null and b/textures/scaffolding_wooden_scaffolding.png differ diff --git a/textures/scaffolding_wooden_scaffolding_top.png b/textures/scaffolding_wooden_scaffolding_top.png new file mode 100644 index 0000000..50b8b57 Binary files /dev/null and b/textures/scaffolding_wooden_scaffolding_top.png differ