diff options
| author | jussi | 2022-11-11 19:23:35 +0200 |
|---|---|---|
| committer | jussi | 2022-11-11 19:23:35 +0200 |
| commit | 921ed3b07f4e8c643161a08744b75562055077ff (patch) | |
| tree | ee10fca564fd0c9417aa6c40561e994446748549 /src/main.c | |
| parent | 1094b1f833553c26125affddf991f8c7f72da225 (diff) | |
| download | reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.gz reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.bz2 reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.zip | |
Lua interpreter mode and easings module.
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 44 |
1 files changed, 34 insertions, 10 deletions
@@ -13,12 +13,26 @@ inline static void printVersion() { int main( int argn, const char **argc ) { char exePath[ STRING_LEN ] = { '\0' }; + bool interpret_mode = false; if ( 1 < argn ) { if ( strcmp( argc[1], "--version" ) == 0 || strcmp( argc[1], "-v" ) == 0 ) { printVersion(); return 1; } + else if ( strcmp( argc[1], "--help" ) == 0 || strcmp( argc[1], "-h" ) == 0 ) { + printf( +"Usage: ReiLua [Options] [Directory to main.lua or main]\nOptions:\n-h --help\tThis help\n-v --version\tShow ReiLua version\n-i --interpret\tInterpret mode [File name]\n" ); + + return 1; + } + else if ( strcmp( argc[1], "--interpret" ) == 0 || strcmp( argc[1], "-i" ) == 0 ) { + interpret_mode = true; + + if ( 2 < argn ) { + sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[2] ); + } + } else{ sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[1] ); } @@ -26,19 +40,29 @@ int main( int argn, const char **argc ) { else { sprintf( exePath, "%s/", GetWorkingDirectory() ); } - printVersion(); - stateInit( exePath ); - while ( state->run ) { - if ( WindowShouldClose() ) { - state->run = false; - } - if ( IsAudioDeviceReady() ) { - UpdateMusicStream( state->music ); + if ( interpret_mode ) { + stateInitInterpret(); + luaL_dofile( state->luaState, exePath ); + } + else { + printVersion(); + stateInit( exePath ); + luaRegister(); + state->run = luaCallMain(); + + while ( state->run ) { + if ( WindowShouldClose() ) { + state->run = false; + } + if ( IsAudioDeviceReady() ) { + UpdateMusicStream( state->music ); + } + luaCallProcess(); + luaCallDraw(); } - luaCallProcess(); - luaCallDraw(); } + stateFree(); return 1; |
