Add flib_position.abs()

This commit is contained in:
Caleb Heuer
2024-10-22 22:10:55 -06:00
parent 98ae780d9a
commit 9306675636
2 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ Version: 0.16.0
Date: ????
Features:
- Added `flib_data_util.all()`, `flib_data_util.get()` for interacting with prototypes via their base type.
- Added `flib_position.abs()`.
Bugfixes:
- Removed icon mipmaps properties from `data-util`; icon mipmaps are now automatically deduced by the game engine.
- Fixed a crash when attempting to use the `gui-templates` module due to an outdated require path. (#72)

View File

@@ -15,6 +15,18 @@ local flib_position = {}
--- FIXME: Sumneko doesn't properly handle generics yet and throws a bunch of bogus warnings.
--- @diagnostic disable
--- Return the absolute value of the position's coordinates.
--- @generic P
--- @param pos P
--- @return P
function flib_position.abs(pos)
if pos.x then
return { x = math.abs(pos.x), y = math.abs(pos.y) }
else
return { math.abs(pos[1]), math.abs(pos[2]) }
end
end
--- Add two positions.
--- @generic P
--- @param pos1 P