summaryrefslogtreecommitdiff
path: root/examples/resources/lib
diff options
context:
space:
mode:
authorjussi2023-07-02 17:44:24 +0300
committerjussi2023-07-02 17:44:24 +0300
commit8ad725429292be22086d51df285907742be7a91a (patch)
tree41c13c146bb3f3f82ade36c2518d105a72b2a5dc /examples/resources/lib
parent0e77452a1b4f894e342dae5583f8b02f915e8f6d (diff)
downloadreilua-enhanced-8ad725429292be22086d51df285907742be7a91a.tar.gz
reilua-enhanced-8ad725429292be22086d51df285907742be7a91a.tar.bz2
reilua-enhanced-8ad725429292be22086d51df285907742be7a91a.zip
LuaJIT compatibility.
Diffstat (limited to 'examples/resources/lib')
-rw-r--r--examples/resources/lib/bitlib.lua23
-rw-r--r--examples/resources/lib/utillib.lua24
-rw-r--r--examples/resources/lib/vector2.lua16
-rw-r--r--examples/resources/lib/vector3.lua16
4 files changed, 49 insertions, 30 deletions
diff --git a/examples/resources/lib/bitlib.lua b/examples/resources/lib/bitlib.lua
new file mode 100644
index 0000000..e794d32
--- /dev/null
+++ b/examples/resources/lib/bitlib.lua
@@ -0,0 +1,23 @@
+local bitlib = {}
+
+function bitlib.setBit( v, i, b )
+ if b then
+ return v | 1 << i
+ else
+ return v & ~( 1 << i )
+ end
+end
+
+function bitlib.toggleBit( v, i )
+ return v ~ ( 1 << i )
+end
+
+function bitlib.getBit( v, i )
+ if v == nil then
+ return false
+ end
+
+ return v & ( 1 << i ) > 0
+end
+
+return bitlib \ No newline at end of file
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 920ebd7..ed4e787 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -41,27 +41,6 @@ function utillib.clamp( val, min, max )
return math.max( min, math.min( val, max ) )
end
--- Returns changed value ( value to be changed, index, state( bool ) )
-function utillib.setBit( v, i, b )
- if b then
- return v | 1 << i
- else
- return v & ~( 1 << i )
- end
-end
-
-function utillib.toggleBit( v, i )
- return v ~ ( 1 << i )
-end
-
-function utillib.getBit( v, i )
- if v == nil then
- return false
- end
-
- return v & ( 1 << i ) > 0
-end
-
function utillib.utf8Sub( s, i, j )
i = i or 1
j = j or -1
@@ -114,9 +93,6 @@ function utillib.split( str, sep )
for str in string.gmatch( str, "([^"..sep.."]+)" ) do
table.insert( t, str )
end
- -- for s in string.gmatch( str, "([^"..sep.."]+)" ) do
- -- table.insert( t, s )
- -- end
return t
end
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
diff --git a/examples/resources/lib/vector3.lua b/examples/resources/lib/vector3.lua
index c2a7b10..9e3ceb1 100644
--- a/examples/resources/lib/vector3.lua
+++ b/examples/resources/lib/vector3.lua
@@ -1,3 +1,8 @@
+-- For luaJit compatibility.
+if table.unpack == nil then
+ table.unpack = unpack
+end
+
Vector3 = {}
Vector3.meta = {
__index = Vector3,
@@ -25,9 +30,6 @@ Vector3.meta = {
__unm = function( v )
return Vector3:new( -v.x, -v.y, -v.z )
end,
- __idiv = function( v, value )
- return Vector3:new( v.x // value, v.y // value, v.z // value )
- end,
__len = function( v )
local len = 0
@@ -94,6 +96,14 @@ function Vector3:max( v2 )
return Vector3:new( RL.Vector3Max( self, v2 ) )
end
+function Vector3:floor()
+ return Vector3:new( math.floor( self.x ), math.floor( self.y ), math.floor( self.z ) )
+end
+
+function Vector3:ceil()
+ return Vector3:new( math.ceil( self.x ), math.ceil( self.y ), math.ceil( self.z ) )
+end
+
function Vector3:addValue( value )
return Vector3:new( RL.Vector3AddValue( self, value ) )
end