Skip to content

Commit

Permalink
Allow percentages in [random_placement]num_items=
Browse files Browse the repository at this point in the history
(cherry-picked from commit 229d2f0)
  • Loading branch information
CelticMinstrel committed Oct 7, 2018
1 parent 0131631 commit d726124
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion changelog.md
Expand Up @@ -5,7 +5,7 @@
* Support [filter_weapon] in leadership and resistance abilities,
which activates the ability only when the affected unit is using
a matching weapon.
* Support WFL in [random_placement]num_items=
* Support WFL and percentages in [random_placement]num_items=
### Language and i18n
* Fixed many cases of interpolated strings in the engine possibly having
their translations retrieved from the wrong textdomain and falling back
Expand Down
2 changes: 2 additions & 0 deletions data/lua/wml/random_placement.lua
Expand Up @@ -18,6 +18,8 @@ wesnoth.wml_actions.random_placement = function(cfg)
local params = {size = #locs}
local result = wesnoth.eval_formula(num_items)
num_items = math.floor(tonumber(result))
elseif num_items:match('^%d+%%$') then
num_items = tonumber(num_items:sub(1,-2))
else
wesnoth.deprecated_message('num_items=lua', 2, '1.17.0', 'Use of Lua for [random_placement]num_items is deprecated. Use WFL instead and enclose the whole thing in parentheses.')
num_items = math.floor(load("local size = " .. #locs .. "; return " .. num_items)())
Expand Down

0 comments on commit d726124

Please sign in to comment.