in custom functions that use variables: set the right prefix
This commit is contained in:
parent
b7c2354cd9
commit
ab0e9faf14
@ -212,10 +212,12 @@ yl_speak_up.custom_functions_p_[ "compare_variable_against_variable" ] = {
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
local owner = yl_speak_up.npc_owner[ n_id ]
|
||||
local prefix = "$ "..tostring(owner).." "
|
||||
-- get the value of the variable
|
||||
-- the owner is alrady encoded in the variable name
|
||||
local var_val_1 = yl_speak_up.get_quest_variable_value(pname, p.p_param1)
|
||||
local var_val_2 = yl_speak_up.get_quest_variable_value(pname, p.p_param2)
|
||||
-- the owner is usually alrady encoded in the variable name - but not here, so
|
||||
-- we need to add it manually
|
||||
local var_val_1 = yl_speak_up.get_quest_variable_value(pname, prefix..p.p_param1)
|
||||
local var_val_2 = yl_speak_up.get_quest_variable_value(pname, prefix..p.p_param2)
|
||||
-- the comparison function below takes its parameters mostly in the form
|
||||
-- of entries in the table tmp_precon - thus, we construct a table with
|
||||
-- fitting entries
|
||||
@ -420,8 +422,10 @@ yl_speak_up.custom_functions_r_[ "set_variable_to_random_number" ] = {
|
||||
end
|
||||
local new_value = math.random(n1, n2)
|
||||
-- the owner is already encoded in the variable name
|
||||
local ret = yl_speak_up.set_quest_variable_value(pname, r.r_param1, new_value)
|
||||
local pname = player:get_player_name()
|
||||
local owner = yl_speak_up.npc_owner[ n_id ]
|
||||
local prefix = "$ "..tostring(owner).." "
|
||||
local ret = yl_speak_up.set_quest_variable_value(pname, prefix..r.r_param1, new_value)
|
||||
local o_id = yl_speak_up.speak_to[pname].o_id or "?"
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"state: Success: "..tostring(ret).." for setting "..tostring(r.r_param1).." to "..
|
||||
@ -448,8 +452,10 @@ yl_speak_up.custom_functions_r_[ "set_variable_to_random_value_from_list" ] = {
|
||||
end
|
||||
local new_value = liste[math.random(1, #liste)]
|
||||
-- the owner is already encoded in the variable name
|
||||
local ret = yl_speak_up.set_quest_variable_value(pname, r.r_param1, new_value)
|
||||
local pname = player:get_player_name()
|
||||
local owner = yl_speak_up.npc_owner[ n_id ]
|
||||
local prefix = "$ "..tostring(owner).." "
|
||||
local ret = yl_speak_up.set_quest_variable_value(pname, prefix..r.r_param1, new_value)
|
||||
local o_id = yl_speak_up.speak_to[pname].o_id or "?"
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"state: Success: "..tostring(ret).." for setting "..tostring(r.r_param1).." to "..
|
||||
|
@ -35,14 +35,14 @@ yl_speak_up.load_quest_variables = function()
|
||||
io.input(file)
|
||||
local text = io.read()
|
||||
-- all values saved in the tables as such are strings
|
||||
local data = minetest.parse_json(text, -1)
|
||||
local data = minetest.parse_json(text, "$NIL_VALUE$")
|
||||
io.close(file)
|
||||
|
||||
if(type(data) ~= "table") then
|
||||
return
|
||||
end
|
||||
for k,v in pairs(data) do
|
||||
if(v == -1) then
|
||||
if(v == "$NIL_VALUE$") then
|
||||
data[ k ] = {}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user