Fixed [role] not working if type= was not specified

This commit is contained in:
Elvish_Hunter 2015-09-21 12:29:13 +02:00
parent acdc67fe56
commit 650f21e582

View file

@ -1308,8 +1308,11 @@ function wml_actions.role(cfg)
local filter = helper.shallow_literal(cfg)
local types = {}
for value in utils.split(cfg.type) do
table.insert(types, utils.trim(value))
if cfg.type then
for value in utils.split(cfg.type) do
table.insert(types, utils.trim(value))
end
end
filter.role, filter.type = nil, nil
@ -1343,11 +1346,12 @@ function wml_actions.role(cfg)
i = i + 1
until #types == 0 or i > #types
-- no matching unit found, fail silently
-- no matching unit found, issue a warning
wesnoth.message("WML", "No matching units found in [role]")
end
function wml_actions.unsynced(cfg)
wesnoth.unsynced(function ()
wml_actions.command(cfg)
end)
end
end