Add suffix= and prefix= operations to [set_variable]

This commit is contained in:
Celtic Minstrel 2018-03-04 21:23:46 -05:00
parent e117e2cede
commit aa0a3bebd1
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Version 1.13.11+dev:
* [set_menu_item] no longer fires repeatedly if the player holds the
hotkey (bug #1711). If you were relying on repeated firing, add
repeat_on_hold=yes to [default_hotkey].
* [set_variable] now supports prefix and suffix operations for
string concatenation.
* Miscellaneous and bug fixes:
* Fixed standing animation toggle not taking immediate effect (bug
#1653).

View File

@ -15,6 +15,14 @@ function wesnoth.wml_actions.set_variable(cfg)
wesnoth.set_variable(name, wesnoth.get_variable(cfg.to_variable))
end
if cfg.suffix then
wesnoth.set_variable(name, (wesnoth.get_variable(name) or '') .. (cfg.suffix or ''))
end
if cfg.prefix then
wesnoth.set_variable(name, (cfg.prefix or '') .. (wesnoth.get_variable(name) or ''))
end
if cfg.add then
wesnoth.set_variable(name, (tonumber(wesnoth.get_variable(name)) or 0) + (tonumber(cfg.add) or 0))
end