From 8db66e8551072517131c108eb77a88b77e8e7e17 Mon Sep 17 00:00:00 2001 From: MrTitainin Date: Thu, 11 Feb 2021 19:45:21 +0100 Subject: [PATCH] Fixed lua [teleport] code And changed [unstore_unit] to use table.unpack for shorter code --- data/lua/wml-tags.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/data/lua/wml-tags.lua b/data/lua/wml-tags.lua index 8600cf5153e..a87eed89d83 100644 --- a/data/lua/wml-tags.lua +++ b/data/lua/wml-tags.lua @@ -839,8 +839,7 @@ wml_actions.unstore_unit = function(cfg) local x = cfg.x or unit.x or -1 local y = cfg.y or unit.y or -1 if cfg.location_id then - local loc = wesnoth.special_locations[cfg.location_id] - x,y = loc[1], loc[2] + x,y = table.unpack(wesnoth.special_locations[cfg.location_id]) end wesnoth.add_known_unit(unit.type) if on_board(x, y) then @@ -878,10 +877,10 @@ wml_actions.teleport = function(cfg) return end local x,y = cfg.x, cfg.y - if not x or not y then - x,y = wesnoth.special_locations[cfg.location_id] + if cfg.location_id then + x,y = table.unpack(wesnoth.special_locations[cfg.location_id]) end - wesnoth.teleport(unit, cfg.x, cfg.y, cfg.check_passability == false, cfg.clear_shroud ~= false, cfg.animate) + wesnoth.teleport(unit, x, y, cfg.check_passability == false, cfg.clear_shroud ~= false, cfg.animate) end function wml_actions.remove_sound_source(cfg)