mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-19 13:48:02 +02:00
fixed bug in effects when the variable is nil
This commit is contained in:
parent
bbc778f0ef
commit
5cab21449d
@ -454,19 +454,39 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
-- quest_step and maximum are effectively the same
|
||||
-- TODO: later on, quest steps may be strings
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
if(var_value) then
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
else
|
||||
new_value = r.r_var_cmp_value
|
||||
end
|
||||
elseif(r.r_operator and r.r_operator == "maximum") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
if(var_value) then
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
else
|
||||
new_value = r.r_var_cmp_value
|
||||
end
|
||||
elseif(r.r_operator and r.r_operator == "minimum") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.min(var_val, r.r_var_cmp_value)
|
||||
if(var_value) then
|
||||
new_value = math.min(var_val, r.r_var_cmp_value)
|
||||
else
|
||||
new_value = r.r_var_cmp_value
|
||||
end
|
||||
elseif(r.r_operator and r.r_operator == "increment") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = var_val + r.r_var_cmp_value
|
||||
if(var_value) then
|
||||
new_value = var_val + r.r_var_cmp_value
|
||||
else
|
||||
new_value = r.r_var_cmp_value
|
||||
end
|
||||
elseif(r.r_operator and r.r_operator == "decrement") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = var_val - r.r_var_cmp_value
|
||||
if(var_value) then
|
||||
new_value = var_val + r.r_var_cmp_value
|
||||
else
|
||||
new_value = -1 * r.r_var_cmp_value
|
||||
end
|
||||
else
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"state: Unsupported type: "..tostring(r.r_value)..".")
|
||||
|
Loading…
Reference in New Issue
Block a user