mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-20 16:05:19 +00:00
Allow WFL for [random_placement]num_items=
(cherry-picked from commit e4a2c141776124c4e0b16677265c4623a4a02aad)
This commit is contained in:
parent
d7d3bc692b
commit
0131631220
@ -5,6 +5,7 @@
|
|||||||
* Support [filter_weapon] in leadership and resistance abilities,
|
* Support [filter_weapon] in leadership and resistance abilities,
|
||||||
which activates the ability only when the affected unit is using
|
which activates the ability only when the affected unit is using
|
||||||
a matching weapon.
|
a matching weapon.
|
||||||
|
* Support WFL in [random_placement]num_items=
|
||||||
### Language and i18n
|
### Language and i18n
|
||||||
* Fixed many cases of interpolated strings in the engine possibly having
|
* Fixed many cases of interpolated strings in the engine possibly having
|
||||||
their translations retrieved from the wrong textdomain and falling back
|
their translations retrieved from the wrong textdomain and falling back
|
||||||
|
@ -14,9 +14,16 @@ wesnoth.wml_actions.random_placement = function(cfg)
|
|||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
local locs = wesnoth.get_locations(filter)
|
local locs = wesnoth.get_locations(filter)
|
||||||
if type(num_items) == "string" then
|
if type(num_items) == "string" then
|
||||||
|
if num_items:match('^%s%(.*%)%s$') then
|
||||||
|
local params = {size = #locs}
|
||||||
|
local result = wesnoth.eval_formula(num_items)
|
||||||
|
num_items = math.floor(tonumber(result))
|
||||||
|
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)())
|
num_items = math.floor(load("local size = " .. #locs .. "; return " .. num_items)())
|
||||||
print("num_items=" .. num_items .. ", #locs=" .. #locs)
|
print("num_items=" .. num_items .. ", #locs=" .. #locs)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local size = #locs
|
local size = #locs
|
||||||
for i = 1, num_items do
|
for i = 1, num_items do
|
||||||
if size == 0 then
|
if size == 0 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user