[Lua] Make f.is_loc work either with a location object or with separate x,y parameters

This commit is contained in:
Celtic Minstrel 2024-02-07 00:09:26 -05:00 committed by Celtic Minstrel
parent e92ee5cb1b
commit a72ec39f79

View file

@ -411,10 +411,14 @@ if wesnoth.kernel_type() == "Mapgen Lua Kernel" then
return { "y", terrain }
end,
---Match a specific location
---@param loc location
---@param x integer
---@param y integer
---@return terrain_filter_tag
is_loc = function(loc)
return f.all(f.x(loc[1]), f.y(loc[2]))
---@overload fun(loc:location):terrain_filter_tag
is_loc = function(x, y)
local loc = wesnoth.map.read_location(x, y)
if not loc then return { "any" } end
return f.all(f.x(loc.x), f.y(loc.y))
end,
---Match terrain by Wesnoth Formula Language
---@param formula string|formula