mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 23:33:44 +01:00
prevent fermenter and reformer from disappearing if placed somewhere they don't fit
This commit is contained in:
parent
a80bad678b
commit
68e30349ae
@ -97,7 +97,8 @@ local function place_top(pos, facedir, placer)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name ~= "air" then
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
if not def or not def.buildable_to then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
minetest.add_node(pos, {name="tubelib_addons1:fermenter_top", param2=facedir})
|
minetest.add_node(pos, {name="tubelib_addons1:fermenter_top", param2=facedir})
|
||||||
@ -186,12 +187,14 @@ minetest.register_node("tubelib_addons1:fermenter", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||||
|
State:node_init(pos, number)
|
||||||
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return
|
minetest.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
|
||||||
State:node_init(pos, number)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||||
@ -252,13 +255,15 @@ minetest.register_node("tubelib_addons1:fermenter_defect", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||||
|
State:node_init(pos, number)
|
||||||
|
State:defect(pos, M(pos))
|
||||||
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return
|
minetest.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
|
||||||
State:node_init(pos, number)
|
|
||||||
State:defect(pos, M(pos))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||||
|
@ -91,7 +91,8 @@ local function place_top(pos, facedir, placer)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name ~= "air" then
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
if not def or not def.buildable_to then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
minetest.add_node(pos, {name="tubelib_addons1:reformer_top", param2=facedir})
|
minetest.add_node(pos, {name="tubelib_addons1:reformer_top", param2=facedir})
|
||||||
@ -182,12 +183,14 @@ minetest.register_node("tubelib_addons1:reformer", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||||
|
State:node_init(pos, number)
|
||||||
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return
|
minetest.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
|
||||||
State:node_init(pos, number)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||||
@ -248,13 +251,15 @@ minetest.register_node("tubelib_addons1:reformer_defect", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||||
|
State:node_init(pos, number)
|
||||||
|
State:defect(pos, M(pos))
|
||||||
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return
|
minetest.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
|
||||||
State:node_init(pos, number)
|
|
||||||
State:defect(pos, M(pos))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||||
|
Loading…
Reference in New Issue
Block a user