summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorjussi2022-11-11 19:23:35 +0200
committerjussi2022-11-11 19:23:35 +0200
commit921ed3b07f4e8c643161a08744b75562055077ff (patch)
treeee10fca564fd0c9417aa6c40561e994446748549 /src/main.c
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 'src/main.c')
-rw-r--r--src/main.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 9155cd7..2e07e37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;