summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2023-08-18 01:23:30 +0300
committerjussi2023-08-18 01:23:30 +0300
commitc911ba043116e9d0e321311ddf27b0170d74410b (patch)
treee51f7141a16400f794d535f999a37ed176271861
parentb7b46ada041ad56b1bc84fea3062464b702135c5 (diff)
downloadreilua-enhanced-c911ba043116e9d0e321311ddf27b0170d74410b.tar.gz
reilua-enhanced-c911ba043116e9d0e321311ddf27b0170d74410b.tar.bz2
reilua-enhanced-c911ba043116e9d0e321311ddf27b0170d74410b.zip
RL.event function with input events.
-rw-r--r--API.md71
-rw-r--r--ReiLua_API.lua18
-rw-r--r--changelog1
-rw-r--r--devnotes2
-rw-r--r--doc_parser.lua17
-rw-r--r--examples/events/main.lua80
-rw-r--r--include/lua_core.h2
-rw-r--r--include/state.h7
-rw-r--r--src/lua_core.c264
9 files changed, 431 insertions, 31 deletions
diff --git a/API.md b/API.md
index b8de792..e13d45d 100644
--- a/API.md
+++ b/API.md
@@ -2,7 +2,7 @@
## Usage
-Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.log' and 'RL.exit'.
+Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'.
---
> function RL.init()
@@ -23,6 +23,12 @@ This function will be called every frame after process and it should have all re
---
+> function RL.event( event )
+
+This function will be called on events input. Content of event table is determined by event type.
+
+---
+
> function RL.log( logLevel, message )
This function can be used for custom log message handling.
@@ -35,6 +41,47 @@ This function will be called on program close. Cleanup could be done here.
---
+## Events
+
+Event content in RL.event.
+
+---
+> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods }
+
+ GLFW3 Keyboard Callback, runs on key pressed.
+
+---
+
+> { type RL.EVENT_CHAR, int key }
+
+ GLFW3 Char Key Callback, runs on key pressed (get char value).
+
+---
+
+> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods }
+
+ GLFW3 Mouse Button Callback, runs on mouse button pressed.
+
+---
+
+> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y }
+
+ GLFW3 Cursor Position Callback, runs on mouse move.
+
+---
+
+> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset }
+
+ GLFW3 Srolling Callback, runs on mouse wheel.
+
+---
+
+> { type RL.EVENT_CURSOR_ENTER, int enter }
+
+ GLFW3 Cursor Enter Callback, cursor enters client area.
+
+---
+
## Globals - ConfigFlags
FLAG_VSYNC_HINT
@@ -1159,6 +1206,28 @@ GL_NEAREST
GL_LINEAR
+## Globals - GLFW
+
+GLFW_RELEASE
+
+GLFW_PRESS
+
+GLFW_REPEAT
+
+## Globals - Event
+
+EVENT_KEY
+
+EVENT_CHAR
+
+EVENT_MOUSE_BUTTON
+
+EVENT_MOUSE_CURSOR_POS
+
+EVENT_MOUSE_SCROLL
+
+EVENT_CURSOR_ENTER
+
## Types
Raylib structs in Lua
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index d00fd2e..0b1551f 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -11,6 +11,9 @@ function RL.init() end
function RL.process( delta ) end
---This function will be called every frame after process and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.
function RL.draw() end
+---This function will be called on events input. Content of event table is determined by event type.
+---@param event table
+function RL.event( event ) end
---This function can be used for custom log message handling.
---@param logLevel integer
---@param message string
@@ -695,6 +698,21 @@ RL.GL_DEPTH_BUFFER_BIT=256
RL.GL_STENCIL_BUFFER_BIT=1024
RL.GL_NEAREST=9728
RL.GL_LINEAR=9729
+
+-- Globals - GLFW
+
+RL.GLFW_RELEASE=0
+RL.GLFW_PRESS=1
+RL.GLFW_REPEAT=2
+
+-- Globals - Event
+
+RL.EVENT_KEY=0
+RL.EVENT_CHAR=1
+RL.EVENT_MOUSE_BUTTON=2
+RL.EVENT_MOUSE_CURSOR_POS=3
+RL.EVENT_MOUSE_SCROLL=4
+RL.EVENT_CURSOR_ENTER=5
-- Core - Window
---Check if window has been initialized successfully
diff --git a/changelog b/changelog
index d8e1c39..8129cad 100644
--- a/changelog
+++ b/changelog
@@ -32,6 +32,7 @@ KEY CHANGES:
- ADDED: logLevelInvalid for bad function calls and invalid data formats.
- ADDED: rlgl Vertex buffers state.
- ADDED: rlgl Shader state.
+ - ADDED: RL.event function with input events.
Detailed changes:
- FIXED: uluaGetRay was looking for integers instead of tables
diff --git a/devnotes b/devnotes
index cdb1381..a868bd9 100644
--- a/devnotes
+++ b/devnotes
@@ -1,4 +1,6 @@
Current {
+ * Events
+ * Window events
* rlgl
* Vertex buffers management
* Matrix state management
diff --git a/doc_parser.lua b/doc_parser.lua
index 0a30be4..b9c1e57 100644
--- a/doc_parser.lua
+++ b/doc_parser.lua
@@ -87,12 +87,13 @@ apiFile:write( "# ReiLua API\n" )
-- Usage.
apiFile:write( "\n## Usage\n" )
-apiFile:write( "\nApplication needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.log' and 'RL.exit'.\n" )
+apiFile:write( "\nApplication needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'.\n" )
local FUNC_DESC = {
init = "This function will be called first when 'main.lua' is found",
process = "This function will be called every frame during execution. It will get time duration from last frame on argument 'delta'",
draw = "This function will be called every frame after process and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.",
+ event = "This function will be called on events input. Content of event table is determined by event type.",
log = "This function can be used for custom log message handling.",
exit = "This function will be called on program close. Cleanup could be done here.",
}
@@ -100,9 +101,21 @@ local FUNC_DESC = {
apiFile:write( "\n---\n> function RL.init()\n\n"..FUNC_DESC.init.."\n\n---\n" )
apiFile:write( "\n> function RL.process( delta )\n\n"..FUNC_DESC.process.."\n\n---\n" )
apiFile:write( "\n> function RL.draw()\n\n"..FUNC_DESC.draw.."\n\n---\n" )
+apiFile:write( "\n> function RL.event( event )\n\n"..FUNC_DESC.event.."\n\n---\n" )
apiFile:write( "\n> function RL.log( logLevel, message )\n\n"..FUNC_DESC.log.."\n\n---\n" )
apiFile:write( "\n> function RL.exit()\n\n"..FUNC_DESC.exit.."\n\n---\n" )
+-- Events.
+
+apiFile:write( "\n## Events\n" )
+apiFile:write( "\nEvent content in RL.event.\n" )
+apiFile:write( "\n---\n> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods }\n\n GLFW3 Keyboard Callback, runs on key pressed.\n\n---\n" )
+apiFile:write( "\n> { type RL.EVENT_CHAR, int key }\n\n GLFW3 Char Key Callback, runs on key pressed (get char value).\n\n---\n" )
+apiFile:write( "\n> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods }\n\n GLFW3 Mouse Button Callback, runs on mouse button pressed.\n\n---\n" )
+apiFile:write( "\n> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y }\n\n GLFW3 Cursor Position Callback, runs on mouse move.\n\n---\n" )
+apiFile:write( "\n> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset }\n\n GLFW3 Srolling Callback, runs on mouse wheel.\n\n---\n" )
+apiFile:write( "\n> { type RL.EVENT_CURSOR_ENTER, int enter }\n\n GLFW3 Cursor Enter Callback, cursor enters client area.\n\n---\n" )
+
luaApiFile:write( "-- Put this file into your project folder to provide annotations when using Lua language server.\n\n" )
luaApiFile:write( "RL={}\n\n" )
luaApiFile:write( "-- Functions.\n\n" )
@@ -114,6 +127,8 @@ luaApiFile:write(
luaApiFile:write(
"---"..FUNC_DESC.draw.."\nfunction RL.draw() end\n" )
luaApiFile:write(
+"---"..FUNC_DESC.event.."\n---@param event table\nfunction RL.event( event ) end\n" )
+luaApiFile:write(
"---"..FUNC_DESC.log.."\n---@param logLevel integer\n---@param message string\nfunction RL.log( logLevel, message ) end\n" )
luaApiFile:write(
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )
diff --git a/examples/events/main.lua b/examples/events/main.lua
new file mode 100644
index 0000000..65f575c
--- /dev/null
+++ b/examples/events/main.lua
@@ -0,0 +1,80 @@
+local text = ""
+local textPos = { 100, 100 }
+local cursorIn = 0
+
+function RL.init()
+ RL.SetWindowTitle( "Events" )
+ RL.SetWindowState( RL.FLAG_VSYNC_HINT )
+end
+
+local function getEventType( event )
+ if event.type == RL.EVENT_KEY then
+ return "Key"
+ elseif event.type == RL.EVENT_CHAR then
+ return "Char"
+ elseif event.type == RL.EVENT_MOUSE_BUTTON then
+ return "Mouse Button"
+ elseif event.type == RL.EVENT_MOUSE_CURSOR_POS then
+ return "Mouse Cursor Position"
+ elseif event.type == RL.EVENT_MOUSE_SCROLL then
+ return "Mouse Scroll"
+ elseif event.type == RL.EVENT_CURSOR_ENTER then
+ return "Cursor Enter"
+ end
+
+ return "Unknown"
+end
+
+local function getAction( action )
+ if action == RL.GLFW_RELEASE then
+ return "Release"
+ elseif action == RL.GLFW_PRESS then
+ return "Press"
+ elseif action == RL.GLFW_REPEAT then
+ return "Repeat"
+ end
+
+ return "Unknown"
+end
+
+local function keyName( key )
+ for item, value in pairs( RL ) do
+ if value == key and string.match( item, "KEY_", 0 ) ~= nil and item ~= "KEY_MENU" then
+ return string.sub( item, 5 )
+ end
+ end
+
+ return "Unknown"
+end
+
+function RL.event( event )
+ text = "Event: "..getEventType( event ).."\n"
+
+ if event.type == RL.EVENT_KEY then
+ text = text.."key: "..event.key.." scancode: "..event.scancode.." action: "..getAction( event.action ).." mods: "..event.mods
+ text = text .."\nkeyName: "..keyName( event.key )
+ elseif event.type == RL.EVENT_CHAR then
+ text = text.."key: "..event.key
+ -- text = text .."\nchar: "..string.char( event.key )
+ text = text .."\nchar: "..utf8.char( event.key )
+ elseif event.type == RL.EVENT_MOUSE_BUTTON then
+ text = text.."button: "..event.button.." action: "..getAction( event.action ).." mods: "..event.mods
+ elseif event.type == RL.EVENT_MOUSE_CURSOR_POS then
+ text = text.."x: "..event.x.." y: "..event.y
+ elseif event.type == RL.EVENT_MOUSE_SCROLL then
+ text = text.."yoffset: "..event.yoffset.." yoffset: "..event.yoffset
+ elseif event.type == RL.EVENT_CURSOR_ENTER then
+ text = text.."enter: "..event.enter
+ cursorIn = event.enter
+ end
+end
+
+function RL.draw()
+ if 0 < cursorIn then
+ RL.ClearBackground( RL.RAYWHITE )
+ else
+ RL.ClearBackground( RL.RED )
+ end
+
+ RL.DrawText( 0, text, textPos, 20, 2, RL.BLACK )
+end
diff --git a/include/lua_core.h b/include/lua_core.h
index 972214e..7c61d07 100644
--- a/include/lua_core.h
+++ b/include/lua_core.h
@@ -1,5 +1,7 @@
#pragma once
+enum EventType { EVENT_KEY, EVENT_CHAR, EVENT_MOUSE_BUTTON, EVENT_MOUSE_CURSOR_POS, EVENT_MOUSE_SCROLL, EVENT_CURSOR_ENTER };
+
void defineGlobals();
void logCustom( int logLevel, const char *text, va_list args );
diff --git a/include/state.h b/include/state.h
index 2082005..ef30dfa 100644
--- a/include/state.h
+++ b/include/state.h
@@ -79,6 +79,13 @@ typedef struct {
Light **lights;
size_t lightCount;
size_t lightAlloc;
+ /* Raylib GLFW input callback events. */
+ GLFWkeyfun raylibKeyCallback;
+ GLFWcharfun raylibCharCallback;
+ GLFWmousebuttonfun raylibMouseButtonCallback;
+ GLFWcursorposfun raylibMouseCursorPosCallback;
+ GLFWscrollfun raylibMouseScrollCallback;
+ GLFWcursorenterfun raylibCursorEnterCallback;
} State;
extern State *state;
diff --git a/src/lua_core.c b/src/lua_core.c
index d14c41e..d8c2f6e 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -614,12 +614,23 @@ void defineGlobals() {
assignGlobalInt( GL_STENCIL_BUFFER_BIT, "GL_STENCIL_BUFFER_BIT" );
assignGlobalInt( GL_NEAREST, "GL_NEAREST" );
assignGlobalInt( GL_LINEAR, "GL_LINEAR" );
+ /* GLFW API tokens. */
+ assignGlobalInt( GLFW_RELEASE, "GLFW_RELEASE" );
+ assignGlobalInt( GLFW_PRESS, "GLFW_PRESS" );
+ assignGlobalInt( GLFW_REPEAT, "GLFW_REPEAT" );
+ /* Event types. */
+ assignGlobalInt( EVENT_KEY, "EVENT_KEY" );
+ assignGlobalInt( EVENT_CHAR, "EVENT_CHAR" );
+ assignGlobalInt( EVENT_MOUSE_BUTTON, "EVENT_MOUSE_BUTTON" );
+ assignGlobalInt( EVENT_MOUSE_CURSOR_POS, "EVENT_MOUSE_CURSOR_POS" );
+ assignGlobalInt( EVENT_MOUSE_SCROLL, "EVENT_MOUSE_SCROLL" );
+ assignGlobalInt( EVENT_CURSOR_ENTER, "EVENT_CURSOR_ENTER" );
/*DOC_END*/
lua_pop( L, -1 );
}
-// Custom logging funtion
+// Custom logging funtion.
void logCustom( int logLevel, const char *text, va_list args ) {
char string[ STRING_LEN ] = {'\0'};
char msg[ STRING_LEN ] = {'\0'};
@@ -661,6 +672,194 @@ void logCustom( int logLevel, const char *text, va_list args ) {
lua_pop( L, -1 );
}
+static void keyInputEvent( GLFWwindow* window, int key, int scancode, int action, int mods ) {
+ /* Pass through to raylib callback. */
+ state->raylibKeyCallback( window, key, scancode, action, mods );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 5, 0 );
+ lua_pushinteger( L, EVENT_KEY );
+ lua_setfield( L, -2, "type" );
+ lua_pushinteger( L, key );
+ lua_setfield( L, -2, "key" );
+ lua_pushinteger( L, scancode );
+ lua_setfield( L, -2, "scancode" );
+ lua_pushinteger( L, action );
+ lua_setfield( L, -2, "action" );
+ lua_pushinteger( L, mods );
+ lua_setfield( L, -2, "mods" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
+static void charInputEvent( GLFWwindow* window, unsigned int key ) {
+ /* Pass through to raylib callback. */
+ state->raylibCharCallback( window, key );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 2, 0 );
+ lua_pushinteger( L, EVENT_CHAR );
+ lua_setfield( L, -2, "type" );
+ lua_pushinteger( L, key );
+ lua_setfield( L, -2, "key" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
+static void mouseButtonInputEvent( GLFWwindow* window, int button, int action, int mods ) {
+ /* Pass through to raylib callback. */
+ state->raylibMouseButtonCallback( window, button, action, mods );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 4, 0 );
+ lua_pushinteger( L, EVENT_MOUSE_BUTTON );
+ lua_setfield( L, -2, "type" );
+ lua_pushinteger( L, button );
+ lua_setfield( L, -2, "button" );
+ lua_pushinteger( L, action );
+ lua_setfield( L, -2, "action" );
+ lua_pushinteger( L, mods );
+ lua_setfield( L, -2, "mods" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
+static void mouseCursorPosInputEvent( GLFWwindow* window, double x, double y ) {
+ /* Pass through to raylib callback. */
+ state->raylibMouseCursorPosCallback( window, x, y );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 3, 0 );
+ lua_pushinteger( L, EVENT_MOUSE_CURSOR_POS );
+ lua_setfield( L, -2, "type" );
+ lua_pushnumber( L, x );
+ lua_setfield( L, -2, "x" );
+ lua_pushnumber( L, y );
+ lua_setfield( L, -2, "y" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
+static void mouseScrollInputEvent( GLFWwindow* window, double xoffset, double yoffset ) {
+ /* Pass through to raylib callback. */
+ state->raylibMouseScrollCallback( window, xoffset, yoffset );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 3, 0 );
+ lua_pushinteger( L, EVENT_MOUSE_SCROLL );
+ lua_setfield( L, -2, "type" );
+ lua_pushnumber( L, xoffset );
+ lua_setfield( L, -2, "xoffset" );
+ lua_pushnumber( L, yoffset );
+ lua_setfield( L, -2, "yoffset" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
+static void cursorEnterInputEvent( GLFWwindow* window, int enter ) {
+ /* Pass through to raylib callback. */
+ state->raylibCursorEnterCallback( window, enter );
+
+ lua_State *L = state->luaState;
+
+ lua_pushcfunction( L, luaTraceback );
+ int tracebackidx = lua_gettop( L );
+
+ lua_getglobal( L, "RL" );
+ lua_getfield( L, -1, "event" );
+
+ if ( lua_isfunction( L, -1 ) ) {
+ lua_createtable( L, 2, 0 );
+ lua_pushinteger( L, EVENT_CURSOR_ENTER );
+ lua_setfield( L, -2, "type" );
+ lua_pushinteger( L, enter );
+ lua_setfield( L, -2, "enter" );
+
+ if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+ TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+ state->run = false;
+ lua_pop( L, -1 );
+ return;
+ }
+ }
+ lua_pop( L, -1 );
+}
+
bool luaInit() {
state->luaState = luaL_newstate();
@@ -728,8 +927,15 @@ bool luaCallMain() {
/* Apply custom callback here. */
SetTraceLogCallback( logCustom );
+ state->raylibKeyCallback = glfwSetKeyCallback( GetWindowHandle(), keyInputEvent );
+ state->raylibCharCallback = glfwSetCharCallback( GetWindowHandle(), charInputEvent );
+ state->raylibMouseButtonCallback = glfwSetMouseButtonCallback( GetWindowHandle(), mouseButtonInputEvent );
+ state->raylibMouseCursorPosCallback = glfwSetCursorPosCallback( GetWindowHandle(), mouseCursorPosInputEvent );
+ state->raylibMouseScrollCallback = glfwSetScrollCallback( GetWindowHandle(), mouseScrollInputEvent );
+ state->raylibCursorEnterCallback = glfwSetCursorEnterCallback( GetWindowHandle(), cursorEnterInputEvent );
+
lua_getglobal( L, "RL" );
- lua_getfield ( L, -1, "init" );
+ lua_getfield( L, -1, "init" );
if ( lua_isfunction( L, -1 ) ) {
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
@@ -754,7 +960,7 @@ void luaCallProcess() {
int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" );
- lua_getfield ( L, -1, "process" );
+ lua_getfield( L, -1, "process" );
if ( lua_isfunction( L, -1 ) ) {
lua_pushnumber( L, GetFrameTime() );
@@ -775,7 +981,7 @@ void luaCallDraw() {
int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" );
- lua_getfield ( L, -1, "draw" );
+ lua_getfield( L, -1, "draw" );
if ( lua_isfunction( L, -1 ) ) {
BeginDrawing();
@@ -797,7 +1003,7 @@ void luaCallExit() {
int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" );
- lua_getfield ( L, -1, "exit" );
+ lua_getfield( L, -1, "exit" );
if ( lua_isfunction( L, -1 ) ) {
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
@@ -2458,38 +2664,38 @@ void uluaPushVector3( lua_State *L, Vector3 vector ) {
void uluaPushVector4( lua_State *L, Vector4 vector ) {
lua_createtable( L, 4, 0 );
- lua_pushnumber( L, vector.x );
- lua_rawseti( L, -2, 1 );
- lua_pushnumber( L, vector.y );
- lua_rawseti( L, -2, 2 );
- lua_pushnumber( L, vector.z );
- lua_rawseti( L, -2, 3 );
- lua_pushnumber( L, vector.w );
- lua_rawseti( L, -2, 4 );
+ lua_pushnumber( L, vector.x );
+ lua_rawseti( L, -2, 1 );
+ lua_pushnumber( L, vector.y );
+ lua_rawseti( L, -2, 2 );
+ lua_pushnumber( L, vector.z );
+ lua_rawseti( L, -2, 3 );
+ lua_pushnumber( L, vector.w );
+ lua_rawseti( L, -2, 4 );
}
void uluaPushRectangle( lua_State *L, Rectangle rect ) {
lua_createtable( L, 4, 0 );
- lua_pushnumber( L, rect.x );
- lua_rawseti( L, -2, 1 );
- lua_pushnumber( L, rect.y );
- lua_rawseti( L, -2, 2 );
- lua_pushnumber( L, rect.width );
- lua_rawseti( L, -2, 3 );
- lua_pushnumber( L, rect.height );
- lua_rawseti( L, -2, 4 );
+ lua_pushnumber( L, rect.x );
+ lua_rawseti( L, -2, 1 );
+ lua_pushnumber( L, rect.y );
+ lua_rawseti( L, -2, 2 );
+ lua_pushnumber( L, rect.width );
+ lua_rawseti( L, -2, 3 );
+ lua_pushnumber( L, rect.height );
+ lua_rawseti( L, -2, 4 );
}
void uluaPushQuaternion( lua_State *L, Quaternion quaternion ) {
lua_createtable( L, 4, 0 );
- lua_pushnumber( L, quaternion.x );
- lua_rawseti( L, -2, 1 );
- lua_pushnumber( L, quaternion.y );
- lua_rawseti( L, -2, 2 );
- lua_pushnumber( L, quaternion.z );
- lua_rawseti( L, -2, 3 );
- lua_pushnumber( L, quaternion.w );
- lua_rawseti( L, -2, 4 );
+ lua_pushnumber( L, quaternion.x );
+ lua_rawseti( L, -2, 1 );
+ lua_pushnumber( L, quaternion.y );
+ lua_rawseti( L, -2, 2 );
+ lua_pushnumber( L, quaternion.z );
+ lua_rawseti( L, -2, 3 );
+ lua_pushnumber( L, quaternion.w );
+ lua_rawseti( L, -2, 4 );
}
void uluaPushMatrix( lua_State *L, Matrix matrix ) {