convert to numbers were necessary in the effects

This commit is contained in:
Sokomine 2021-07-12 00:31:27 +02:00
parent 5cab21449d
commit d16cc44e6c

View File

@ -454,36 +454,36 @@ 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)
if(var_value) then
new_value = math.max(var_val, r.r_var_cmp_value)
if(var_value and tonumber(var_val) and tonumber(r.r_var_cmp_value)) then
new_value = math.max(tonumber(var_val), tonumber(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)
if(var_value) then
new_value = math.max(var_val, r.r_var_cmp_value)
if(var_value and tonumber(var_val) and tonumber(r.r_var_cmp_value)) then
new_value = math.max(tonumber(var_val), tonumber(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)
if(var_value) then
new_value = math.min(var_val, r.r_var_cmp_value)
if(var_value and tonumber(var_val) and tonumber(r.r_var_cmp_value)) then
new_value = math.min(tonumber(var_val), tonumber(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)
if(var_value) then
new_value = var_val + r.r_var_cmp_value
if(var_value and tonumber(var_val) and tonumber(r.r_var_cmp_value)) then
new_value = tonumber(var_val) + tonumber(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)
if(var_value) then
new_value = var_val + r.r_var_cmp_value
if(var_value and tonumber(var_val) and tonumber(r.r_var_cmp_value)) then
new_value = tonumber(var_val) + tonumber(r.r_var_cmp_value)
else
new_value = -1 * r.r_var_cmp_value
end