summaryrefslogtreecommitdiff
path: root/examples/resources/lib/utillib.lua
diff options
context:
space:
mode:
authorjussi2022-11-11 19:23:35 +0200
committerjussi2022-11-11 19:23:35 +0200
commit921ed3b07f4e8c643161a08744b75562055077ff (patch)
treeee10fca564fd0c9417aa6c40561e994446748549 /examples/resources/lib/utillib.lua
parent1094b1f833553c26125affddf991f8c7f72da225 (diff)
downloadreilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.gz
reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.bz2
reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.zip
Lua interpreter mode and easings module.
Diffstat (limited to 'examples/resources/lib/utillib.lua')
-rw-r--r--examples/resources/lib/utillib.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 8d3ce9e..b2b93e0 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -1,4 +1,4 @@
--- Define useful global stuff.
+-- Define useful global functions.
local utillib = {}
@@ -41,7 +41,7 @@ function utillib.clamp( val, min, max )
return math.max( min, math.min( val, max ) )
end
--- Returns changed value ( value to be changed, index, bit )
+-- Returns changed value ( value to be changed, index, state( bool ) )
function utillib.setBit( v, i, b )
if b then
return v | 1 << i
@@ -93,6 +93,7 @@ function utillib.round( v )
return math.tointeger( v + 0.5 - ( v + 0.5 ) % 1 )
end
+-- Use with dictionary style tables.
function utillib.tableLen( t )
local count = 0
@@ -151,4 +152,15 @@ function utillib.toBoolean( v )
return false
end
+-- Print table content.
+function utillib.printt( t )
+ print( tostring(t).." = {" )
+
+ for i, item in pairs( t ) do
+ print( "\t"..tostring(i).." = "..tostring( item ) )
+ end
+
+ print( "}" )
+end
+
return utillib