From 0fcbe67bb9afab6f25130b0218e64d608c7decac Mon Sep 17 00:00:00 2001 From: "Henning P. Schmiedehausen" Date: Tue, 22 Oct 2024 21:53:52 -0700 Subject: [PATCH] [FACTORIO 2.0] Added 8 new directions into defines.direction. If mods are storing any direction values in their storage, they will need to migrate them by multiplying by 2. --- stdlib/area/direction.lua | 10 +++++----- stdlib/area/orientation.lua | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/stdlib/area/direction.lua b/stdlib/area/direction.lua index ab485e3e..3da2078e 100644 --- a/stdlib/area/direction.lua +++ b/stdlib/area/direction.lua @@ -31,7 +31,7 @@ Direction.southwest = defines.direction.southwest -- @tparam defines.direction direction the direction -- @treturn defines.direction the opposite direction function Direction.opposite(direction) - return (direction + 4) % 8 + return (direction + 8) % 16 end --- Returns the next direction. @@ -40,7 +40,7 @@ end -- @tparam[opt=false] boolean eight_way true to get the next direction in 8-way (note: not many prototypes support 8-way) -- @treturn defines.direction the next direction function Direction.next(direction, eight_way) - return (direction + (eight_way and 1 or 2)) % 8 + return (direction + (eight_way and 2 or 4)) % 16 end --- Returns the previous direction. @@ -49,14 +49,14 @@ end -- @tparam[opt=false] boolean eight_way true to get the previous direction in 8-way (note: not many prototypes support 8-way) -- @treturn defines.direction the next direction function Direction.previous(direction, eight_way) - return (direction + (eight_way and -1 or -2)) % 8 + return (direction + (eight_way and -2 or -4)) % 16 end --- Returns an orientation from a direction. -- @tparam defines.direction direction -- @treturn float function Direction.to_orientation(direction) - return direction / 8 + return direction / 16 end --- Returns a vector from a direction. @@ -101,7 +101,7 @@ do end function Direction.next_direction(direction, reverse, eight_way) - return (direction + (eight_way and ((reverse and -1) or 1) or ((reverse and -2) or 2))) % 8 + return (direction + (eight_way and ((reverse and -2) or 2) or ((reverse and -4) or 4))) % 16 end end diff --git a/stdlib/area/orientation.lua b/stdlib/area/orientation.lua index cdea9bcf..d97cc300 100644 --- a/stdlib/area/orientation.lua +++ b/stdlib/area/orientation.lua @@ -9,21 +9,21 @@ local Orientation = { setmetatable(Orientation, Orientation) --- north orientation -Orientation.north = defines.direction.north / 8 +Orientation.north = defines.direction.north / 16 --- east orientation -Orientation.east = defines.direction.east / 8 +Orientation.east = defines.direction.east / 16 --- west orientation -Orientation.west = defines.direction.west / 8 +Orientation.west = defines.direction.west / 16 --- south orientation -Orientation.south = defines.direction.south / 8 +Orientation.south = defines.direction.south / 16 --- northeast orientation -Orientation.northeast = defines.direction.northeast / 8 +Orientation.northeast = defines.direction.northeast / 16 --- northwest orientation -Orientation.northwest = defines.direction.northwest / 8 +Orientation.northwest = defines.direction.northwest / 16 --- southeast orientation -Orientation.southeast = defines.direction.southeast / 8 +Orientation.southeast = defines.direction.southeast / 16 --- southwest orientation -Orientation.southwest = defines.direction.southwest / 8 +Orientation.southwest = defines.direction.southwest / 16 local floor = math.floor @@ -32,8 +32,8 @@ local floor = math.floor -- @tparam[opt=false] boolean eight_way -- @treturn defines.direction function Orientation.to_direction(orientation, eight_way) - local ways = eight_way and 8 or 4 - local mod = eight_way and 1 or 2 + local ways = eight_way and 16 or 8 + local mod = eight_way and 2 or 4 return floor(orientation * ways + 0.5) % ways * mod end