mirror of
https://github.com/factoriolib/flib.git
synced 2025-09-04 08:26:22 +00:00
Add flib_position.abs()
This commit is contained in:
@@ -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)
|
||||
|
12
position.lua
12
position.lua
@@ -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
|
||||
|
Reference in New Issue
Block a user