forked from Sokomine/yl_speak_up
only blocks where the player (npc owner) can build are suitable for preconditions and effects
This commit is contained in:
parent
5c8586cc50
commit
d2e5840886
@ -454,29 +454,39 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
if(not(block_pos) and data and data.block_pos) then
|
||||
block_pos = data.block_pos
|
||||
end
|
||||
local error_is_protected = ""
|
||||
if(block_pos) then
|
||||
-- store for later usage
|
||||
data.block_pos = block_pos
|
||||
local tmp_pos = {x=block_pos.x, y=block_pos.y, z=block_pos.z}
|
||||
-- TODO: effects: the player has to be able to build at that position - check that
|
||||
-- "I can't punch it. The block is as the block *above* the one I punched.",
|
||||
-- (only valid for preconditions; not for effects - because the player and
|
||||
-- his NPC need to be able to build there)
|
||||
if(data.block and id_prefix == "p_" and data.block == 5) then
|
||||
tmp_pos.y = block_pos.y + 1
|
||||
end
|
||||
block_pos_str = minetest.pos_to_string(tmp_pos)
|
||||
node = minetest.get_node_or_nil(tmp_pos)
|
||||
if(not(node)) then
|
||||
node = {name = "- unknown -", param2 = "- unkown -"}
|
||||
-- effects (and, likewise, preconditions): the player at least has to be able to
|
||||
-- build at that position - check that
|
||||
if(minetest.is_protected(tmp_pos, pname)) then
|
||||
error_is_protected = "label[0.2,7.8;Error: "..
|
||||
"The position you punched is protected. It cannot be used by "..
|
||||
"your NPC for checks or building. Please select a diffrent block!]"
|
||||
block_pos = nil
|
||||
data.block_pos = nil
|
||||
else
|
||||
block_pos_str = minetest.pos_to_string(tmp_pos)
|
||||
node = minetest.get_node_or_nil(tmp_pos)
|
||||
if(not(node)) then
|
||||
node = {name = "- unknown -", param2 = "- unkown -"}
|
||||
end
|
||||
-- "There shall be air instead of this block.",
|
||||
-- (only valid for preconditions)
|
||||
if(data.block and id_prefix == "p_" and data.block == 3) then
|
||||
node = {name = "air", param2 = 0}
|
||||
end
|
||||
-- cache that (in case a sapling grows or someone else changes it)
|
||||
data.node_data = node
|
||||
end
|
||||
-- "There shall be air instead of this block.",
|
||||
-- (only valid for preconditions)
|
||||
if(data.block and id_prefix == "p_" and data.block == 3) then
|
||||
node = {name = "air", param2 = 0}
|
||||
end
|
||||
-- cache that (in case a sapling grows or someone else changes it)
|
||||
data.node_data = node
|
||||
end
|
||||
if(node.name == "- unknown -") then
|
||||
save_button = ""
|
||||
@ -501,7 +511,8 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
"tooltip[select_block_pos;Click on this button to select a block.\n"..
|
||||
"This menu will close and you will be asked to punch\n"..
|
||||
"the block at the position you want to check or change.\n"..
|
||||
"After punching it, you will be returned to this menu.]"
|
||||
"After punching it, you will be returned to this menu.]"..
|
||||
error_is_protected
|
||||
|
||||
-- "a trade", -- 4
|
||||
-- (trade - only for preconditions; effects have something else here)
|
||||
|
Loading…
Reference in New Issue
Block a user