Fixed bug where unit at x1,y1 would be considered for object even if filter failed

Note that this was only present the 1.13 Lua implementation of [object]
and as such does not affect 1.12
This commit is contained in:
Charles Dang 2015-09-20 10:18:12 +11:00
parent 6a3a346e41
commit 9ea9c88356

View file

@ -13,16 +13,15 @@ function wml_actions.object(cfg)
local obj_id = utils.check_key(cfg.id, "id", "object", true)
if obj_id and used_items[obj_id] then return end
local unit
local filter = helper.get_child(cfg, "filter")
if filter then
local unit, command_type, text
if helper.get_child(cfg, "filter") then
unit = wesnoth.get_units(filter)[1]
end
if not unit then
else
unit = wesnoth.get_unit(contxt.x, context.y)
end
local command_type, text
-- If a unit matches the filter, proceed
if unit then
text = tostring(cfg.description or "")
command_type = "then"