mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 15:23:43 +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
|
||||
end
|
||||
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
|
||||
end
|
||||
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)
|
||||
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
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
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.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- 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)
|
||||
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
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
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.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- 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
|
||||
end
|
||||
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
|
||||
end
|
||||
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)
|
||||
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
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
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.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- 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)
|
||||
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
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
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.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||
|
Loading…
Reference in New Issue
Block a user