fix modify_unit split_to_array function

This commit is contained in:
ProditorMagnus 2018-11-11 13:18:34 +02:00 committed by gfgtdf
parent e8ccf2a4de
commit e3da41335e

View file

@ -7,7 +7,7 @@ local wml_actions = wesnoth.wml_actions
-- in the first part of this file and the fallback (old) implementation in the -- in the first part of this file and the fallback (old) implementation in the
-- second part of this file -- second part of this file
local function split_to_array(s, res) local function split_to_array(str, sep)
-- Split string @str into a table using the delimiter @sep (default: ',') -- Split string @str into a table using the delimiter @sep (default: ',')
local sep, fields = sep or ",", {} local sep, fields = sep or ",", {}
@ -24,7 +24,7 @@ local function make_set(t)
return res return res
end end
local knwon_attributes = make_set { local known_attributes = make_set {
"x", "x",
"y", "y",
"ai_special", "ai_special",
@ -47,7 +47,7 @@ local knwon_attributes = make_set {
"type", "type",
} }
local knwon_tags = make_set { local known_tags = make_set {
"object", "object",
"advancement", "advancement",
"trait", "trait",
@ -57,11 +57,11 @@ local knwon_tags = make_set {
local function is_simple(cfg) local function is_simple(cfg)
for k, v in pairs(wml.shallow_literal(cfg)) do for k, v in pairs(wml.shallow_literal(cfg)) do
if type(k) == "string" then if type(k) == "string" then
if not knwon_attributes[k] then if not known_attributes[k] then
return false return false
end end
else else
if not knwon_tags[v[1]] then if not known_tags[v[1]] then
return false return false
end end
end end
@ -242,4 +242,4 @@ function wml_actions.modify_unit(cfg)
utils.end_var_scope("this_unit", this_unit) utils.end_var_scope("this_unit", this_unit)
wml.variables[unit_variable] = nil wml.variables[unit_variable] = nil
end end