RL.event function with input events.

This commit is contained in:
jussi
2023-08-18 01:23:30 +03:00
parent b7b46ada04
commit c911ba0431
9 changed files with 431 additions and 31 deletions

71
API.md
View File

@@ -2,7 +2,7 @@
## Usage ## 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() > 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 ) > function RL.log( logLevel, message )
This function can be used for custom log message handling. 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 ## Globals - ConfigFlags
FLAG_VSYNC_HINT FLAG_VSYNC_HINT
@@ -1159,6 +1206,28 @@ GL_NEAREST
GL_LINEAR 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 ## Types
Raylib structs in Lua Raylib structs in Lua

View File

@@ -11,6 +11,9 @@ function RL.init() end
function RL.process( delta ) 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. ---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 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. ---This function can be used for custom log message handling.
---@param logLevel integer ---@param logLevel integer
---@param message string ---@param message string
@@ -695,6 +698,21 @@ RL.GL_DEPTH_BUFFER_BIT=256
RL.GL_STENCIL_BUFFER_BIT=1024 RL.GL_STENCIL_BUFFER_BIT=1024
RL.GL_NEAREST=9728 RL.GL_NEAREST=9728
RL.GL_LINEAR=9729 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 -- Core - Window
---Check if window has been initialized successfully ---Check if window has been initialized successfully

View File

@@ -32,6 +32,7 @@ KEY CHANGES:
- ADDED: logLevelInvalid for bad function calls and invalid data formats. - ADDED: logLevelInvalid for bad function calls and invalid data formats.
- ADDED: rlgl Vertex buffers state. - ADDED: rlgl Vertex buffers state.
- ADDED: rlgl Shader state. - ADDED: rlgl Shader state.
- ADDED: RL.event function with input events.
Detailed changes: Detailed changes:
- FIXED: uluaGetRay was looking for integers instead of tables - FIXED: uluaGetRay was looking for integers instead of tables

View File

@@ -1,4 +1,6 @@
Current { Current {
* Events
* Window events
* rlgl * rlgl
* Vertex buffers management * Vertex buffers management
* Matrix state management * Matrix state management

View File

@@ -87,12 +87,13 @@ apiFile:write( "# ReiLua API\n" )
-- Usage. -- Usage.
apiFile:write( "\n## Usage\n" ) 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 = { local FUNC_DESC = {
init = "This function will be called first when 'main.lua' is found", 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'", 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.", 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.", 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.", 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---\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.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.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.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" ) 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( "-- Put this file into your project folder to provide annotations when using Lua language server.\n\n" )
luaApiFile:write( "RL={}\n\n" ) luaApiFile:write( "RL={}\n\n" )
luaApiFile:write( "-- Functions.\n\n" ) luaApiFile:write( "-- Functions.\n\n" )
@@ -114,6 +127,8 @@ luaApiFile:write(
luaApiFile:write( luaApiFile:write(
"---"..FUNC_DESC.draw.."\nfunction RL.draw() end\n" ) "---"..FUNC_DESC.draw.."\nfunction RL.draw() end\n" )
luaApiFile:write( 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" ) "---"..FUNC_DESC.log.."\n---@param logLevel integer\n---@param message string\nfunction RL.log( logLevel, message ) end\n" )
luaApiFile:write( luaApiFile:write(
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" ) "---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )

80
examples/events/main.lua Normal file
View File

@@ -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

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
enum EventType { EVENT_KEY, EVENT_CHAR, EVENT_MOUSE_BUTTON, EVENT_MOUSE_CURSOR_POS, EVENT_MOUSE_SCROLL, EVENT_CURSOR_ENTER };
void defineGlobals(); void defineGlobals();
void logCustom( int logLevel, const char *text, va_list args ); void logCustom( int logLevel, const char *text, va_list args );

View File

@@ -79,6 +79,13 @@ typedef struct {
Light **lights; Light **lights;
size_t lightCount; size_t lightCount;
size_t lightAlloc; size_t lightAlloc;
/* Raylib GLFW input callback events. */
GLFWkeyfun raylibKeyCallback;
GLFWcharfun raylibCharCallback;
GLFWmousebuttonfun raylibMouseButtonCallback;
GLFWcursorposfun raylibMouseCursorPosCallback;
GLFWscrollfun raylibMouseScrollCallback;
GLFWcursorenterfun raylibCursorEnterCallback;
} State; } State;
extern State *state; extern State *state;

View File

@@ -614,12 +614,23 @@ void defineGlobals() {
assignGlobalInt( GL_STENCIL_BUFFER_BIT, "GL_STENCIL_BUFFER_BIT" ); assignGlobalInt( GL_STENCIL_BUFFER_BIT, "GL_STENCIL_BUFFER_BIT" );
assignGlobalInt( GL_NEAREST, "GL_NEAREST" ); assignGlobalInt( GL_NEAREST, "GL_NEAREST" );
assignGlobalInt( GL_LINEAR, "GL_LINEAR" ); 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*/ /*DOC_END*/
lua_pop( L, -1 ); lua_pop( L, -1 );
} }
// Custom logging funtion // Custom logging funtion.
void logCustom( int logLevel, const char *text, va_list args ) { void logCustom( int logLevel, const char *text, va_list args ) {
char string[ STRING_LEN ] = {'\0'}; char string[ STRING_LEN ] = {'\0'};
char msg[ 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 ); 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() { bool luaInit() {
state->luaState = luaL_newstate(); state->luaState = luaL_newstate();
@@ -728,8 +927,15 @@ bool luaCallMain() {
/* Apply custom callback here. */ /* Apply custom callback here. */
SetTraceLogCallback( logCustom ); 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_getglobal( L, "RL" );
lua_getfield ( L, -1, "init" ); lua_getfield( L, -1, "init" );
if ( lua_isfunction( L, -1 ) ) { if ( lua_isfunction( L, -1 ) ) {
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) { if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
@@ -754,7 +960,7 @@ void luaCallProcess() {
int tracebackidx = lua_gettop(L); int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" ); lua_getglobal( L, "RL" );
lua_getfield ( L, -1, "process" ); lua_getfield( L, -1, "process" );
if ( lua_isfunction( L, -1 ) ) { if ( lua_isfunction( L, -1 ) ) {
lua_pushnumber( L, GetFrameTime() ); lua_pushnumber( L, GetFrameTime() );
@@ -775,7 +981,7 @@ void luaCallDraw() {
int tracebackidx = lua_gettop(L); int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" ); lua_getglobal( L, "RL" );
lua_getfield ( L, -1, "draw" ); lua_getfield( L, -1, "draw" );
if ( lua_isfunction( L, -1 ) ) { if ( lua_isfunction( L, -1 ) ) {
BeginDrawing(); BeginDrawing();
@@ -797,7 +1003,7 @@ void luaCallExit() {
int tracebackidx = lua_gettop(L); int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" ); lua_getglobal( L, "RL" );
lua_getfield ( L, -1, "exit" ); lua_getfield( L, -1, "exit" );
if ( lua_isfunction( L, -1 ) ) { if ( lua_isfunction( L, -1 ) ) {
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) { if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {