Skip to content

Commit

Permalink
Add formula= option to [set_variable] (change by @CelticMinstrel)
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Vultraz committed Feb 2, 2018
1 parent c916a85 commit c8abb8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -66,6 +66,8 @@ Version 1.13.10+dev:
improvement over the uncut ruby of fire (14x4) in TRoW.
* Added [lua] as a conditional tag.
* Lua errors now cause as a condition to fail instead of pass.
* New formula= key in [set_variable] allows evaluating a WFL formula with
the variable, which may be either a scalar or a container.
* Miscellaneous and bug fixes:
* Fixed crash after canceling add-on download (bug #2203)
* Fixed ingame help showing units you haven't encountered (bug #2135)
Expand Down
5 changes: 5 additions & 0 deletions data/lua/wml/set_variable.lua
Expand Up @@ -98,6 +98,11 @@ function wesnoth.wml_actions.set_variable(cfg)
wesnoth.set_variable(name, helper.rand(tostring(cfg.rand)))
end

if cfg.formula then
local fcn = wesnoth.compile_formula(cfg.formula)
wesnoth.set_variable(name, fcn(wesnoth.get_variable(name)))
end

local join_child = helper.get_child(cfg, "join")
if join_child then
local array_name = join_child.variable or helper.wml_error "missing variable= attribute in [join]"
Expand Down

0 comments on commit c8abb8d

Please sign in to comment.