From 1cbadf56f33641e85fc634a326c0db6935947c23 Mon Sep 17 00:00:00 2001 From: jussi Date: Mon, 10 Apr 2023 14:33:15 +0300 Subject: New argument style for gui and easings. --- src/models.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index 3ab5b99..963bd56 100644 --- a/src/models.c +++ b/src/models.c @@ -1728,10 +1728,17 @@ int lmodelsLoadModel( lua_State *L ) { lua_pushinteger( L, -1 ); return 1; } - int i = newModel(); - *state->models[i] = LoadModel( lua_tostring( L, 1 ) ); - lua_pushinteger( L, i ); + if ( FileExists( lua_tostring( L, 1 ) ) ) { + int i = newModel(); + *state->models[i] = LoadModel( lua_tostring( L, 1 ) ); + lua_pushinteger( L, i ); + return 1; + } + else { + lua_pushinteger( L, -1 ); + return 1; + } return 1; } @@ -2063,21 +2070,19 @@ int lmodelsLoadModelAnimations( lua_State *L ) { lua_pushinteger( L, -1 ); return 1; } - int i = 0; - for ( i = 0; i < state->animationCount; i++ ) { - if ( state->animations[i] == NULL ) { - break; - } - } - state->animations[i] = malloc( sizeof( ModelAnimations ) ); - state->animations[i]->animations = LoadModelAnimations( lua_tostring( L, 1 ), &state->animations[i]->animCount ); - checkAnimationRealloc( i ); - - lua_pushinteger( L, i ); - lua_pushinteger( L, state->animations[i]->animCount ); + if ( FileExists( lua_tostring( L, 1 ) ) ) { + int i = newAnimation(); + state->animations[i]->animations = LoadModelAnimations( lua_tostring( L, 1 ), &state->animations[i]->animCount ); + lua_pushinteger( L, i ); + lua_pushinteger( L, state->animations[i]->animCount ); - return 2; + return 2; + } + else { + lua_pushinteger( L, -1 ); + return 1; + } } /* -- cgit v1.2.3