mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-24 16:26:23 +00:00
Bugfixes in [role] tag
The following fixes were applied: * cfg.__shallow_literal -> helper.shallow_literal, to allow calling the tag from Lua as wesnoth.wml_actions.role * added trim() to the for cycle * deleted filter.role and filter.type after having copied their data, because when calling the tag from Lua they ended up being deleted too early * unit.role = cfg.role -> unit.role = role
This commit is contained in:
parent
787bd1b9c5
commit
79d44d0486
@ -1465,14 +1465,15 @@ function wml_actions.role(cfg)
|
||||
-- role= and type= are handled differently than in other tags,
|
||||
-- so we need to remove them from the filter
|
||||
local role = cfg.role
|
||||
local filter = cfg.__shallow_literal
|
||||
filter.role, filter.type = nil, nil
|
||||
local filter = helper.shallow_literal(cfg)
|
||||
|
||||
local types = {}
|
||||
for value in split(cfg.type) do
|
||||
table.insert(types, value)
|
||||
table.insert(types, trim(value))
|
||||
end
|
||||
|
||||
filter.role, filter.type = nil, nil
|
||||
|
||||
-- first attempt to match units on the map
|
||||
local i = 1
|
||||
repeat
|
||||
@ -1482,7 +1483,7 @@ function wml_actions.role(cfg)
|
||||
end
|
||||
local unit = wesnoth.get_units(filter)[1]
|
||||
if unit then
|
||||
unit.role = cfg.role
|
||||
unit.role = role
|
||||
return
|
||||
end
|
||||
i = i + 1
|
||||
@ -1496,7 +1497,7 @@ function wml_actions.role(cfg)
|
||||
end
|
||||
local unit = wesnoth.get_recall_units(filter)[1]
|
||||
if unit then
|
||||
unit.role = cfg.role
|
||||
unit.role = role
|
||||
return
|
||||
end
|
||||
i = i + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user