Compare commits
5 Commits
2bbec5116b
...
930edb43d2
Author | SHA1 | Date |
---|---|---|
adrido | 930edb43d2 | |
Adrian | 0fb0cfea17 | |
Infinatum | 9e47250b38 | |
Infinatum | 2ec270e1a1 | |
Infinatum | 0154a67673 |
|
@ -1,81 +1,4 @@
|
|||
scaffolding_nodenames={"scaffolding:scaffolding","scaffolding:iron_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:platform","scaffolding:iron_platform"}
|
||||
|
||||
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 --
|
||||
|
||||
|
@ -114,5 +37,3 @@ function default.dig_horz2(pos, node, digger)
|
|||
minetest.node_dig(np, nn, digger)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
243
init.lua
|
@ -1,4 +1,59 @@
|
|||
local buildPlatform = function(node, pos, itemstack)
|
||||
-- code for the building platforms
|
||||
posZ = {'1', '0', '-1', '-1', '0', '0', '1', '1' };
|
||||
posX = {'0', '-1', '0', '0', '1', '1', '0', '0' };
|
||||
|
||||
for nameCount = 1, 8 do
|
||||
pos.z = pos.z + posZ[nameCount];
|
||||
pos.x = pos.x + posX[nameCount];
|
||||
local current_node = minetest.get_node(pos);
|
||||
if current_node.name == "air" then
|
||||
minetest.set_node(pos, {name = node} )
|
||||
itemstack:take_item(1); --//and remove one if its the correct one
|
||||
break;
|
||||
end
|
||||
end
|
||||
-- end of function
|
||||
end
|
||||
|
||||
local buildScaffolding = function(node, pos, itemstack, player)
|
||||
-- many thanks to addi for improveing (rewriteing) my crappy code --
|
||||
|
||||
-- code for the building scaffolding
|
||||
height = 0;
|
||||
depth = 0; -- !!Note!! depth is not needed at the moment
|
||||
|
||||
|
||||
--[[ debug stuff ]]
|
||||
|
||||
|
||||
-- set pos at bottom of scafolding tower.
|
||||
repeat
|
||||
pos.y = pos.y - 1; --every run get one node up
|
||||
depth = depth - 1
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
|
||||
|
||||
until current_node.name ~= node -- will repeat untill it dose not find a scaffolding node
|
||||
|
||||
|
||||
-- check height of scaffolding tower --
|
||||
|
||||
repeat
|
||||
pos.y = pos.y + 1; --every run get one node up
|
||||
height = height + 1
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
|
||||
|
||||
if current_node.name == "air" then
|
||||
minetest.set_node(pos, {name = node } )
|
||||
itemstack:take_item(1); --//and remove one if its the correct one
|
||||
player:set_wielded_item(itemstack);--//update inventory of the player
|
||||
end
|
||||
until current_node.name ~= node or height >= 32 --we repeat until we find something else then "scaffolding:scaffolding"
|
||||
--maybe there should be also another limit, because its currently possible to build infinite towers
|
||||
|
||||
end
|
||||
|
||||
print("scaffolding: Loading 'functions.lua'")
|
||||
dofile(minetest.get_modpath("scaffolding").."/functions.lua")
|
||||
|
@ -29,77 +84,23 @@ minetest.register_node("scaffolding:scaffolding", {
|
|||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
-- if user hits scaffolding with platform Wooden scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:platform" then
|
||||
|
||||
--arrayZ ( 1, 0, -1, -1, 0, 0, 1, 1 );
|
||||
-- arrayX( 0, -1, 0, 0, 1, 1, 0, 0 );
|
||||
|
||||
local name = minetest.get_node(pos).name
|
||||
|
||||
posZ = {'1', '0', '-1', '-1', '0', '0', '1', '1' };
|
||||
posX = {'0', '-1', '0', '0', '1', '1', '0', '0' };
|
||||
|
||||
for nameCount = 1, 8 do
|
||||
pos.z = pos.z + posZ[nameCount];
|
||||
pos.x = pos.x + posX[nameCount];
|
||||
local current_node = minetest.get_node(pos);
|
||||
if current_node.name == "air" then
|
||||
minetest.set_node(pos, {name = "scaffolding:platform"} )
|
||||
itemstack:take_item(1); --//and remove one if its the correct one
|
||||
break;
|
||||
end
|
||||
end
|
||||
node = "scaffolding:platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
|
||||
-- if user hits scaffolding with platform Iron scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:iron_platform" then
|
||||
node = "scaffolding:iron_platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
-- if user hits scaffolding with scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:scaffolding" then
|
||||
|
||||
-- many thanks to addi for improveing (rewriteing) my crappy code --
|
||||
node = "scaffolding:scaffolding";
|
||||
local name = minetest.get_node(pos).name -- get loacation of node
|
||||
height = 0;
|
||||
depth = 0; -- !!Note!! depth is not needed at the moment
|
||||
|
||||
--[[ debug stuff ]]
|
||||
minetest.chat_send_all(string.format("node: %s",name))
|
||||
|
||||
minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z ))
|
||||
|
||||
-- set pos at bottom of scafolding tower.
|
||||
repeat
|
||||
pos.y = pos.y - 1; --every run get one node up
|
||||
depth = depth - 1
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
minetest.chat_send_all(string.format("found %q at location: %s",
|
||||
current_node.name,
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
|
||||
until current_node.name ~= "scaffolding:scaffolding" -- will repeat untill it dose not find a scaffolding node
|
||||
minetest.chat_send_all(string.format("exit loop"))
|
||||
|
||||
-- check height of scaffolding tower --
|
||||
|
||||
repeat
|
||||
pos.y = pos.y + 1; --every run get one node up
|
||||
height = height + 1
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
minetest.chat_send_all(string.format("found %q at location: %s",
|
||||
current_node.name,
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
|
||||
if current_node.name == "air" then
|
||||
minetest.set_node(pos, {name = "scaffolding:scaffolding"} )
|
||||
itemstack:take_item(1); --//and remove one if its the correct one
|
||||
player:set_wielded_item(itemstack);--//update inventory of the player
|
||||
end
|
||||
until current_node.name ~= "scaffolding:scaffolding" or height >= 32 --we repeat until we find something else then "scaffolding:scaffolding"
|
||||
--maybe there should be also another limit, because its currently possible to build infinite towers
|
||||
minetest.chat_send_all(string.format("exit loop"))
|
||||
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
buildScaffolding(node, pos, itemstack, player)
|
||||
end
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -124,6 +125,7 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
"scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png"},
|
||||
drop = "scaffolding:scaffolding",
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
paramtype2 = "facedir",
|
||||
climbable = true,
|
||||
walkable = false,
|
||||
|
@ -138,21 +140,18 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
|
||||
end
|
||||
end,
|
||||
--[[ on_rightclick = function(pos, node, puncher)
|
||||
local tool = puncher:get_wielded_item():get_name()
|
||||
if tool and tool == "scaffolding:scaffolding_wrench" then
|
||||
node.name = "scaffolding:scaffolding"
|
||||
minetest.env:set_node(pos, node)
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
-- if user hits scaffolding with platform Wooden scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:platform" then
|
||||
node = "scaffolding:platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
-- if user hits scaffolding with platform Iron scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:iron_platform" then
|
||||
node = "scaffolding:iron_platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
local tool = puncher:get_wielded_item():get_name()
|
||||
if tool and tool == "scaffolding:scaffolding_wrench" then
|
||||
node.name = "air"
|
||||
minetest.env:set_node(pos, node)
|
||||
puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
|
||||
end
|
||||
end,]]
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -208,6 +207,7 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
minetest.register_node("scaffolding:reinforced_platform", {
|
||||
description = "Wooden Platform",
|
||||
drawtype = "nodebox",
|
||||
light_source = 14,
|
||||
tiles = {"scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png", "scaffolding_wooden_scaffolding.png^scaffolding_reinforced.png", "scaffolding_wooden_scaffolding.png^scaffolding_platform.png"},
|
||||
drop = "scaffolding:platform",
|
||||
paramtype = "light",
|
||||
|
@ -271,52 +271,21 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
-- if user hits scaffolding with platform Iron scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:iron_platform" then
|
||||
node = "scaffolding:iron_platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
-- if user hits scaffolding with platform Wooden scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:platform" then
|
||||
node = "scaffolding:platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
-- if user hits scaffolding with scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:iron_scaffolding" then
|
||||
|
||||
-- many thanks to addi for improveing (rewriteing) my crappy code --
|
||||
node = "scaffolding:iron_scaffolding";
|
||||
local name = minetest.get_node(pos).name -- get loacation of node
|
||||
height = 0;
|
||||
depth = 0; -- !!Note!! depth is not deeded at the moment
|
||||
|
||||
--[[ debug stuff ]]
|
||||
minetest.chat_send_all(string.format("node: %s",name))
|
||||
|
||||
minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z ))
|
||||
|
||||
-- set pos at bottom of scafolding tower.
|
||||
repeat
|
||||
pos.y = pos.y - 1; --every run get one node up
|
||||
depth = depth - 1 -- !!Note!! depth is not needed at the moment
|
||||
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
minetest.chat_send_all(string.format("found %q at location: %s",
|
||||
current_node.name,
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
|
||||
until current_node.name ~= "scaffolding:iron_scaffolding" -- will repeat untill it dose not find a scaffolding node
|
||||
minetest.chat_send_all(string.format("exit loop"))
|
||||
|
||||
-- check height of scaffolding tower --
|
||||
|
||||
repeat
|
||||
pos.y = pos.y + 1; --every run get one node up
|
||||
height = height + 1
|
||||
local current_node = minetest.get_node(pos); --get the node of the new position
|
||||
minetest.chat_send_all(string.format("found %q at location: %s",
|
||||
current_node.name,
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
|
||||
if current_node.name == "air" then
|
||||
minetest.set_node(pos, {name = "scaffolding:iron_scaffolding"} )
|
||||
itemstack:take_item(1); --//and remove one if its the correct one
|
||||
player:set_wielded_item(itemstack);--//update inventory of the player
|
||||
end
|
||||
until current_node.name ~= "scaffolding:iron_scaffolding" or height >= 32 --we repeat until we find something else then "scaffolding:scaffolding"
|
||||
--maybe there should be also another limit, because its currently possible to build infinite towers
|
||||
minetest.chat_send_all(string.format("exit loop"))
|
||||
|
||||
buildScaffolding(node, pos, itemstack, player)
|
||||
end
|
||||
|
||||
end,
|
||||
|
@ -335,6 +304,7 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
paramtype2 = "facedir",
|
||||
climbable = true,
|
||||
walkable = false,
|
||||
light_source = 14,
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,cracky=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
@ -346,22 +316,18 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
|
||||
end
|
||||
end,
|
||||
--[[on_rightclick = function(pos, node, puncher)
|
||||
local tool = puncher:get_wielded_item():get_name()
|
||||
if tool and tool == "scaffolding:scaffolding_wrench" then
|
||||
node.name = "scaffolding:iron_scaffolding"
|
||||
minetest.env:set_node(pos, node)
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
-- if user hits scaffolding with platform Iron scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:iron_platform" then
|
||||
node = "scaffolding:iron_platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
-- if user hits scaffolding with platform Wooden scaffolding then --
|
||||
if itemstack:get_name() == "scaffolding:platform" then
|
||||
node = "scaffolding:platform";
|
||||
buildPlatform(node, pos, itemstack)
|
||||
end
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
local tool = puncher:get_wielded_item():get_name()
|
||||
if tool and tool == "scaffolding:scaffolding_wrench" then
|
||||
node.name = "air"
|
||||
minetest.env:set_node(pos, node)
|
||||
--puncher:get_inventory():remove_item("main", ItemStack("beer_test:tankard"))
|
||||
puncher:get_inventory():add_item("main", ItemStack("scaffolding:scaffolding"))
|
||||
end
|
||||
end,]]
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -423,6 +389,7 @@ minetest.register_node("scaffolding:reinforced_scaffolding", {
|
|||
paramtype2 = "facedir",
|
||||
climbable = false,
|
||||
walkable = true,
|
||||
light_source = 14,
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,cracky=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
|
Before Width: | Height: | Size: 484 B After Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 407 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 441 B |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 714 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 555 B |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 481 B |