Support formula= in [variable] ConditionalWML

(cherry-picked from commit 4e52d62963)
This commit is contained in:
Celtic Minstrel 2018-03-24 18:08:29 -04:00
parent 66ad656805
commit d2a465a126

View file

@ -18,3 +18,18 @@ function wesnoth.wml_conditionals.lua(cfg)
return bytecode(wml.get_child(cfg, "args"))
end
end
-- Add formula= to [variable]
-- Doesn't work for array variables though
local old_variable = wesnoth.wml_conditionals.variable
function wesnoth.wml_conditionals.variable(cfg)
if cfg.formula then
local value = wml.variables[cfg.name]
local result = wesnoth.eval_formula(cfg.formula, {value = value})
-- WFL considers 0 as false; Lua doesn't
if result == 0 then return false end
return result
else
return old_variable(cfg)
end
end