Argumets stored in RL.arg array.
This commit is contained in:
6
API.md
6
API.md
@@ -1,6 +1,6 @@
|
||||
# ReiLua API
|
||||
|
||||
## Usage
|
||||
## Functions
|
||||
|
||||
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'.
|
||||
|
||||
@@ -41,6 +41,10 @@ This function will be called on program close. Cleanup could be done here.
|
||||
|
||||
---
|
||||
|
||||
## Arguments
|
||||
|
||||
Arguments are stored in 'RL.arg' array.
|
||||
|
||||
## Globals - ConfigFlags
|
||||
FLAG_VSYNC_HINT = 64
|
||||
FLAG_FULLSCREEN_MODE = 2
|
||||
|
||||
@@ -20,6 +20,8 @@ function RL.event( event ) end
|
||||
function RL.log( logLevel, message ) end
|
||||
---This function will be called on program close. Cleanup could be done here.
|
||||
function RL.exit() end
|
||||
---This function will be called on program close. Cleanup could be done here.
|
||||
function RL.exit() end
|
||||
|
||||
-- Globals - ConfigFlags
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ Detailed changes:
|
||||
- FIXED: isValidRenderTexture checks that it is TEXTURE_TYPE_RENDER_TEXTURE
|
||||
- FIXED: isValidTexture on CreateMaterial
|
||||
- CHANGED: Renamed start, end arguments to a, b to avoid using Lua keyword "end" in argument names
|
||||
- ADDED: Argumets stored in "RL.arg" array
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||
|
||||
@@ -86,7 +86,7 @@ apiFile:write( "# ReiLua API\n" )
|
||||
|
||||
-- Usage.
|
||||
|
||||
apiFile:write( "\n## Usage\n" )
|
||||
apiFile:write( "\n## Functions\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 = {
|
||||
@@ -121,6 +121,11 @@ 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" )
|
||||
luaApiFile:write(
|
||||
"---"..FUNC_DESC.exit.."\nfunction RL.exit() end\n" )
|
||||
|
||||
apiFile:write( "\n## Arguments\n" )
|
||||
apiFile:write( "\nArguments are stored in 'RL.arg' array.\n" )
|
||||
|
||||
-- Globals.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ enum EventType {
|
||||
EVENT_CURSOR_ENTER
|
||||
};
|
||||
|
||||
bool luaInit();
|
||||
bool luaInit( int argn, const char **argc );
|
||||
int luaTraceback( lua_State *L );
|
||||
bool luaCallMain();
|
||||
void luaCallProcess();
|
||||
|
||||
@@ -97,6 +97,6 @@ typedef struct {
|
||||
|
||||
extern State *state;
|
||||
|
||||
bool stateInit( const char *exePath );
|
||||
void stateInitInterpret();
|
||||
bool stateInit( int argn, const char **argc, const char *exePath );
|
||||
void stateInitInterpret( int argn, const char **argc );
|
||||
void stateFree();
|
||||
|
||||
@@ -1007,18 +1007,32 @@ static void cursorEnterInputEvent( GLFWwindow* window, int enter ) {
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
bool luaInit() {
|
||||
bool luaInit( int argn, const char **argc ) {
|
||||
state->luaState = luaL_newstate();
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_openlibs( state->luaState );
|
||||
luaL_openlibs( L );
|
||||
|
||||
if ( state->luaState == NULL ) {
|
||||
if ( L == NULL ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Failed to init Lua" );
|
||||
|
||||
return false;
|
||||
}
|
||||
defineGlobals();
|
||||
|
||||
/* Set arguments. */
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_newtable( L );
|
||||
lua_setfield( L, -2, "arg" );
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "arg" );
|
||||
|
||||
for ( int i = 0; i < argn; i++ ) {
|
||||
lua_pushstring( L, argc[i] );
|
||||
lua_rawseti( L, -2, i + 1 );
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ int main( int argn, const char **argc ) {
|
||||
}
|
||||
|
||||
if ( interpret_mode ) {
|
||||
stateInitInterpret();
|
||||
stateInitInterpret( argn, argc );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
@@ -63,7 +63,7 @@ int main( int argn, const char **argc ) {
|
||||
}
|
||||
else {
|
||||
printVersion();
|
||||
stateInit( exePath );
|
||||
stateInit( argn, argc, exePath );
|
||||
luaRegister();
|
||||
state->run = luaCallMain();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
State *state;
|
||||
|
||||
bool stateInit( const char *exePath ) {
|
||||
bool stateInit( int argn, const char **argc, const char *exePath ) {
|
||||
state = malloc( sizeof( State ) );
|
||||
|
||||
state->exePath = malloc( STRING_LEN * sizeof( char ) );
|
||||
@@ -107,15 +107,15 @@ bool stateInit( const char *exePath ) {
|
||||
}
|
||||
if ( state->run ) {
|
||||
InitAudioDevice();
|
||||
state->run = luaInit();
|
||||
state->run = luaInit( argn, argc );
|
||||
}
|
||||
|
||||
return state->run;
|
||||
}
|
||||
|
||||
void stateInitInterpret() {
|
||||
void stateInitInterpret( int argn, const char **argc ) {
|
||||
state = malloc( sizeof( State ) );
|
||||
luaInit();
|
||||
luaInit( argn, argc );
|
||||
}
|
||||
|
||||
void stateFree() {
|
||||
|
||||
Reference in New Issue
Block a user