fix [store_side] to allow explicit indexes

[store_side] variable= some_variable[0] ... [/store_side] would result in a wesnoth.set_variable(some_variable[0][0]. ...)  call which we don't allow in master after https://github.com/wesnoth/wesnoth/pull/231. 1.12 would just ignore the second index in this case. I decided to rather fix [store_side] than to restore the 1.12 behaviour of set_variable (which wouldn't be harder).
This commit is contained in:
gfgtdf 2015-01-05 17:11:27 +01:00
parent 46fc0d4d93
commit 201d83f608

View file

@ -1072,8 +1072,11 @@ end
function wml_actions.store_side(cfg)
local variable = cfg.variable or "side"
local is_explicit_index = string.sub(str, string.len(str)) == "]"
local index = 0
wesnoth.set_variable(variable)
if not is_explicit_index then
wesnoth.set_variable(variable)
end
for t, side_number in helper.get_sides(cfg) do
local container = {
controller = t.controller,
@ -1094,7 +1097,11 @@ function wml_actions.store_side(cfg)
flag_icon = t.flag_icon,
side = side_number
}
wesnoth.set_variable(string.format("%s[%u]", variable, index), container)
if is_explicit_index then
wesnoth.set_variable(variable, container)
else
wesnoth.set_variable(string.format("%s[%u]", variable, index), container)
end
index = index + 1
end
end