From 8ad725429292be22086d51df285907742be7a91a Mon Sep 17 00:00:00 2001 From: jussi Date: Sun, 2 Jul 2023 17:44:24 +0300 Subject: LuaJIT compatibility. --- examples/resources/lib/vector2.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'examples/resources/lib/vector2.lua') diff --git a/examples/resources/lib/vector2.lua b/examples/resources/lib/vector2.lua index 65452cf..8f9ad1d 100644 --- a/examples/resources/lib/vector2.lua +++ b/examples/resources/lib/vector2.lua @@ -1,3 +1,8 @@ +-- For luaJit compatibility. +if table.unpack == nil then + table.unpack = unpack +end + Vector2 = {} Vector2.meta = { __index = Vector2, @@ -25,9 +30,6 @@ Vector2.meta = { __unm = function( v ) return Vector2:new( -v.x, -v.y ) end, - __idiv = function( v, value ) - return Vector2:new( v.x // value, v.y // value ) - end, __len = function( v ) local len = 0 @@ -90,6 +92,14 @@ function Vector2:max( v2 ) return Vector2:new( math.max( self.x, v2.x ), math.max( self.y, v2.y ) ) end +function Vector2:floor() + return Vector2:new( math.floor( self.x ), math.floor( self.y ) ) +end + +function Vector2:ceil() + return Vector2:new( math.ceil( self.x ), math.ceil( self.y ) ) +end + function Vector2:addValue( value ) return Vector2:new( RL.Vector2AddValue( self, value ) ) end -- cgit v1.2.3