fixed bug with data.what used before data

This commit is contained in:
Sokomine 2021-09-03 21:29:37 +02:00
parent 412ae94c1b
commit ad063f2e0a

View File

@ -301,7 +301,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
-- "the inventory of the player", -- 5
-- "the inventory of the NPC", -- 6
-- (only for preconditions; not for effects)
elseif((what_type == "player_inv" or what_type == "npc_inv") and id_prefix == "p_") then
elseif((what_type == "player_inv" or what_type == "npc_inv" or what_type == "block_inv") and id_prefix == "p_") then
v.p_value = values_inv[ data.inv ]
if(v.p_value and v.p_value ~= "inv_is_empty") then
if(not(data.inv_stack_name) or data.inv_stack_name == "") then
@ -732,19 +732,19 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
-- field inputs: those do not trigger a sending of the formspec on their own
local was_changed = false
-- are we talking about an inventory?
-- (inventory only applies to preconditions; not effects)
local data = yl_speak_up.speak_to[pname][ tmp_data_cache ]
local what_type = ""
if(data and data.what and values_what[ data.what ]) then
what_type = values_what[ data.what ]
end
local was_changed = false
-- are we talking about an inventory?
-- (inventory only applies to preconditions; not effects)
local data = yl_speak_up.speak_to[pname][ tmp_data_cache ]
if(((fields.inv_stack_name and fields.inv_stack_name ~= "")
or (fields.store_item_name and fields.store_item_name ~= ""))
and data and data.what
and ((id_prefix == "p_" and (what_type == "player_inv" or what_type == "npc_inv"))
and ((id_prefix == "p_" and (what_type == "player_inv" or what_type == "npc_inv" or what_type == "block_inv"))
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 7
-- "take item from player and destroy it (requires npc_master priv)", -- 8
or (id_prefix == "r_" and (what_type == "give_item" or what_type == "take_item")))) then
@ -1273,7 +1273,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
-- "the inventory of the player", -- 5
-- "the inventory of the NPC", -- 6
-- (inventory - only for preconditions; effects have something else here)
elseif(data.what and id_prefix == "p_" and (what_type == "player_inv" or what_type == "npc_inv")) then
elseif(data.what and id_prefix == "p_" and (what_type == "player_inv" or what_type == "npc_inv" or what_type == "block_inv")) then
return yl_speak_up.get_fs_edit_option_precondition_inv(
pname, dialog, formspec, data, id_prefix, save_button, e,
values_inv, check_inv)