Support formula= in [variable] ConditionalWML
(cherry-picked from commit 4e52d62963
)
This commit is contained in:
parent
66ad656805
commit
d2a465a126
1 changed files with 15 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue