summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2023-04-07 21:24:14 +0300
committerjussi2023-04-07 21:24:14 +0300
commit6dad6544d7196905668b4863487daa00ac9843f7 (patch)
treed6c365c90d3a1e8c8e8a368703ac4b6826fce491 /src
parent22f70cf06f75cd5022e622a9d14a56b67e74a157 (diff)
downloadreilua-enhanced-6dad6544d7196905668b4863487daa00ac9843f7.tar.gz
reilua-enhanced-6dad6544d7196905668b4863487daa00ac9843f7.tar.bz2
reilua-enhanced-6dad6544d7196905668b4863487daa00ac9843f7.zip
Audio and shapes now use new argumet style.
Diffstat (limited to 'src')
-rw-r--r--src/audio.c234
-rw-r--r--src/shapes.c569
-rw-r--r--src/textures.c1
3 files changed, 353 insertions, 451 deletions
diff --git a/src/audio.c b/src/audio.c
index d62fcfd..5649ab1 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -53,6 +53,34 @@ static void checkWaveRealloc( int i ) {
}
}
+static int newSound() {
+ int i = 0;
+
+ for ( i = 0; i < state->soundCount; i++ ) {
+ if ( state->sounds[i] == NULL ) {
+ break;
+ }
+ }
+ state->sounds[i] = malloc( sizeof( Sound ) );
+ checkSoundRealloc( i );
+
+ return i;
+}
+
+static int newWave() {
+ int i = 0;
+
+ for ( i = 0; i < state->waveCount; i++ ) {
+ if ( state->waves[i] == NULL ) {
+ break;
+ }
+ }
+ state->waves[i] = malloc( sizeof( Wave ) );
+ checkWaveRealloc( i );
+
+ return i;
+}
+
/*
## Audio - Audio device management
*/
@@ -66,12 +94,14 @@ Set master volume ( listener )
- Success return true
*/
int laudioSetMasterVolume( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMasterVolume( float volume )" );
lua_pushboolean( L, false );
return 1;
}
- SetMasterVolume( lua_tonumber( L, -1 ) );
+ float volume = lua_tonumber( L, 1 );
+
+ SetMasterVolume( volume );
lua_pushboolean( L, true );
return 1;
@@ -90,30 +120,22 @@ Load sound from file
- Success return int
*/
int laudioLoadSound( lua_State *L ) {
- if ( !lua_isstring( L, -1 ) ) {
+ if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSound( string fileName )" );
lua_pushinteger( L, -1 );
return 1;
}
- if ( FileExists( lua_tostring( L, -1 ) ) ) {
- int i = 0;
-
- for ( i = 0; i < state->soundCount; i++ ) {
- if ( state->sounds[i] == NULL ) {
- break;
- }
- }
- state->sounds[i] = malloc( sizeof( Sound ) );
- *state->sounds[i] = LoadSound( lua_tostring( L, -1 ) );
+ if ( FileExists( lua_tostring( L, 1 ) ) ) {
+ int i = newSound();
+ *state->sounds[i] = LoadSound( lua_tostring( L, 1 ) );
lua_pushinteger( L, i );
- checkSoundRealloc( i );
+ return 1;
}
else {
lua_pushinteger( L, -1 );
+ return 1;
}
-
- return 1;
}
/*
@@ -125,29 +147,22 @@ Load wave data from file
- Success return int
*/
int laudioLoadWave( lua_State *L ) {
- if ( !lua_isstring( L, -1 ) ) {
+ if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadWave( string fileName )" );
lua_pushinteger( L, -1 );
return 1;
}
- if ( FileExists( lua_tostring( L, -1 ) ) ) {
- int i = 0;
-
- for ( i = 0; i < state->waveCount; i++ ) {
- if ( state->waves[i] == NULL ) {
- break;
- }
- }
- state->waves[i] = malloc( sizeof( Wave ) );
- *state->waves[i] = LoadWave( lua_tostring( L, -1 ) );
+ if ( FileExists( lua_tostring( L, 1 ) ) ) {
+ int i = newWave();
+ *state->waves[i] = LoadWave( lua_tostring( L, 1 ) );
lua_pushinteger( L, i );
- checkWaveRealloc( i );
+ return 1;
}
else {
lua_pushinteger( L, -1 );
+ return 1;
}
- return 1;
}
/*
@@ -159,28 +174,20 @@ Load sound from wave data
- Success return int
*/
int laudioLoadSoundFromWave( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSoundFromWave( Wave wave )" );
lua_pushinteger( L, -1 );
return 1;
}
- size_t waveId = lua_tointeger( L, -1 );
+ size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( waveId ) ) {
lua_pushinteger( L, -1 );
return 1;
}
- int i = 0;
-
- for ( i = 0; i < state->soundCount; i++ ) {
- if ( state->sounds[i] == NULL ) {
- break;
- }
- }
- state->sounds[i] = malloc( sizeof( Sound ) );
+ int i = newSound();
*state->sounds[i] = LoadSoundFromWave( *state->waves[ waveId ] );
lua_pushinteger( L, i );
- checkSoundRealloc( i );
return 1;
}
@@ -194,19 +201,19 @@ Unload sound
- Success return true
*/
int laudioUnloadSound( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadSound( Sound sound )" );
lua_pushboolean( L, false );
return 1;
}
- size_t id = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
- if ( !validSound( id ) ) {
+ if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
return 1;
}
- UnloadSound( *state->sounds[ id ] );
- state->sounds[ id ] = NULL;
+ UnloadSound( *state->sounds[ soundId ] );
+ state->sounds[ soundId ] = NULL;
lua_pushboolean( L, true );
return 1;
@@ -221,19 +228,19 @@ Unload wave data
- Success return true
*/
int laudioUnloadWave( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadWave( Wave wave )" );
lua_pushboolean( L, false );
return 1;
}
- size_t id = lua_tointeger( L, -1 );
+ size_t waveId = lua_tointeger( L, 1 );
- if ( !validWave( id ) ) {
+ if ( !validWave( waveId ) ) {
lua_pushboolean( L, false );
return 1;
}
- UnloadWave( *state->waves[ id ] );
- state->waves[ id ] = NULL;
+ UnloadWave( *state->waves[ waveId ] );
+ state->waves[ waveId ] = NULL;
lua_pushboolean( L, true );
return 1;
@@ -248,18 +255,18 @@ Export wave data to file, returns true on success
- Success return true
*/
int laudioExportWave( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWave( Wave wave, string fileName )" );
lua_pushboolean( L, false );
return 1;
}
- size_t id = lua_tointeger( L, -2 );
+ size_t waveId = lua_tointeger( L, 1 );
- if ( !validWave( id ) ) {
+ if ( !validWave( waveId ) ) {
lua_pushboolean( L, false );
return 1;
}
- lua_pushboolean( L, ExportWave( *state->waves[ id ], lua_tostring( L, -1 ) ) );
+ lua_pushboolean( L, ExportWave( *state->waves[ waveId ], lua_tostring( L, 2 ) ) );
return 1;
}
@@ -273,18 +280,18 @@ Export wave sample data to code (.h), returns true on success
- Success return true
*/
int laudioExportWaveAsCode( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWaveAsCode( Wave wave, string fileName )" );
lua_pushboolean( L, false );
return 1;
}
- size_t id = lua_tointeger( L, -2 );
+ size_t waveId = lua_tointeger( L, 1 );
- if ( !validWave( id ) ) {
+ if ( !validWave( waveId ) ) {
lua_pushboolean( L, false );
return 1;
}
- lua_pushboolean( L, ExportWaveAsCode( *state->waves[ id ], lua_tostring( L, -1 ) ) );
+ lua_pushboolean( L, ExportWaveAsCode( *state->waves[ waveId ], lua_tostring( L, 2 ) ) );
return 1;
}
@@ -302,12 +309,12 @@ Play a sound
- Success return true
*/
int laudioPlaySound( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PlaySound( Sound sound )" );
lua_pushboolean( L, false );
return 1;
}
- size_t soundId = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
@@ -328,12 +335,12 @@ Stop playing a sound
- Success return true
*/
int laudioStopSound( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.StopSound( Sound sound )" );
lua_pushboolean( L, false );
return 1;
}
- size_t soundId = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
@@ -354,12 +361,12 @@ Pause a sound
- Success return true
*/
int laudioPauseSound( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PauseSound( Sound sound )" );
lua_pushboolean( L, false );
return 1;
}
- size_t soundId = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
@@ -380,12 +387,12 @@ Resume a paused sound
- Success return true
*/
int laudioResumeSound( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ResumeSound( Sound sound )" );
lua_pushboolean( L, false );
return 1;
}
- size_t soundId = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
@@ -406,12 +413,12 @@ Check if a sound is currently playing
- Success return bool
*/
int laudioIsSoundPlaying( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsSoundPlaying( Sound sound )" );
lua_pushnil( L );
return 1;
}
- size_t soundId = lua_tointeger( L, -1 );
+ size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) {
lua_pushnil( L );
@@ -431,16 +438,19 @@ Set volume for a sound ( 1.0 is max level )
- Success return true
*/
int laudioSetSoundVolume( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundVolume( Sound sound, float volume )" );
lua_pushboolean( L, false );
return 1;
}
- if ( !validSound( lua_tointeger( L, -2 ) ) ) {
+ size_t soundId = lua_tointeger( L, 1 );
+ float volume = lua_tonumber( L, 2 );
+
+ if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
return 1;
}
- SetSoundVolume( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) );
+ SetSoundVolume( *state->sounds[ soundId ], volume );
lua_pushboolean( L, true );
return 1;
@@ -455,16 +465,19 @@ Set pitch for a sound ( 1.0 is base level )
- Success return true
*/
int laudioSetSoundPitch( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPitch( Sound sound, float pitch )" );
lua_pushboolean( L, false );
return 1;
}
- if ( !validSound( lua_tointeger( L, -2 ) ) ) {
+ size_t soundId = lua_tointeger( L, 1 );
+ float pitch = lua_tonumber( L, 2 );
+
+ if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
return 1;
}
- SetSoundPitch( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) );
+ SetSoundPitch( *state->sounds[ soundId ], pitch );
lua_pushboolean( L, true );
return 1;
@@ -479,16 +492,19 @@ Set pan for a sound ( 0.5 is center )
- Success return true
*/
int laudioSetSoundPan( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPan( Sound sound, float pitch )" );
lua_pushboolean( L, false );
return 1;
}
- if ( !validSound( lua_tointeger( L, -2 ) ) ) {
+ size_t soundId = lua_tointeger( L, 1 );
+ float pan = lua_tonumber( L, 2 );
+
+ if ( !validSound( soundId ) ) {
lua_pushboolean( L, false );
return 1;
}
- SetSoundPan( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) );
+ SetSoundPan( *state->sounds[ soundId ], pan );
lua_pushboolean( L, true );
return 1;
@@ -503,15 +519,15 @@ Convert wave data to desired format
- Success return true
*/
int laudioWaveFormat( lua_State *L ) {
- if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels )" );
lua_pushboolean( L, false );
return 1;
}
- int channels = lua_tointeger( L, -1 );
- int sampleSize = lua_tointeger( L, -2 );
- int sampleRate = lua_tointeger( L, -3 );
- size_t waveId = lua_tointeger( L, -4 );
+ size_t waveId = lua_tointeger( L, 1 );
+ int sampleRate = lua_tointeger( L, 2 );
+ int sampleSize = lua_tointeger( L, 3 );
+ int channels = lua_tointeger( L, 4 );
if ( !validWave( waveId ) ) {
lua_pushboolean( L, false );
@@ -532,28 +548,20 @@ Copy a wave to a new wave
- Success return int
*/
int laudioWaveCopy( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCopy( Wave wave )" );
lua_pushinteger( L, -1 );
return 1;
}
- size_t waveId = lua_tointeger( L, -1 );
+ size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( waveId ) ) {
- lua_pushnil( L );
+ lua_pushinteger( L, -1 );
return 1;
}
- int i = 0;
-
- for ( i = 0; i < state->waveCount; i++ ) {
- if ( state->waves[i] == NULL ) {
- break;
- }
- }
- state->waves[i] = malloc( sizeof( Wave ) );
+ int i = newWave();
*state->waves[i] = WaveCopy( *state->waves[ waveId ] );
lua_pushinteger( L, i );
- checkWaveRealloc( i );
return 1;
}
@@ -567,14 +575,14 @@ Crop a wave to defined samples range
- Success return true
*/
int laudioWaveCrop( lua_State *L ) {
- if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCrop( Wave wave, int initSample, int finalSample )" );
lua_pushboolean( L, false );
return 1;
}
- int finalSample = lua_tointeger( L, -1 );
- int initSample = lua_tointeger( L, -2 );
- size_t waveId = lua_tointeger( L, -3 );
+ size_t waveId = lua_tointeger( L, 1 );
+ int initSample = lua_tointeger( L, 2 );
+ int finalSample = lua_tointeger( L, 3 );
if ( !validWave( waveId ) ) {
lua_pushboolean( L, false );
@@ -599,13 +607,13 @@ Load music stream from file
- Success return true
*/
int laudioLoadMusicStream( lua_State *L ) {
- if ( !lua_isstring( L, -1 ) ) {
+ if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadMusicStream( string fileName )" );
lua_pushboolean( L, false );
return 1;
}
- if ( FileExists( lua_tostring( L, -1 ) ) ) {
- state->music = LoadMusicStream( lua_tostring( L, -1 ) );
+ if ( FileExists( lua_tostring( L, 1 ) ) ) {
+ state->music = LoadMusicStream( lua_tostring( L, 1 ) );
state->music.looping = false;
lua_pushboolean( L, true );
@@ -683,12 +691,14 @@ Seek music to a position ( in seconds )
- Success return true
*/
int laudioSeekMusicStream( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SeekMusicStream( float position )" );
lua_pushboolean( L, false );
return 1;
}
- SeekMusicStream( state->music, lua_tonumber( L, -1 ) );
+ float position = lua_tonumber( L, 1 );
+
+ SeekMusicStream( state->music, position );
lua_pushboolean( L, true );
return 1;
@@ -703,12 +713,14 @@ Set volume for music ( 1.0 is max level )
- Success return true
*/
int laudioSetMusicVolume( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicVolume( float volume )" );
lua_pushboolean( L, false );
return 1;
}
- SetMusicVolume( state->music, lua_tonumber( L, -1 ) );
+ float volume = lua_tonumber( L, 1 );
+
+ SetMusicVolume( state->music, volume );
lua_pushboolean( L, true );
return 1;
@@ -723,12 +735,14 @@ Set pitch for a music ( 1.0 is base level )
- Success return true
*/
int laudioSetMusicPitch( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPitch( float pitch )" );
lua_pushboolean( L, false );
return 1;
}
- SetMusicPitch( state->music, lua_tonumber( L, -1 ) );
+ float pitch = lua_tonumber( L, 1 );
+
+ SetMusicPitch( state->music, pitch );
lua_pushboolean( L, true );
return 1;
@@ -743,12 +757,14 @@ Set pan for a music ( 0.5 is center )
- Success return true
*/
int laudioSetMusicPan( lua_State *L ) {
- if ( !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPan( float pan )" );
lua_pushboolean( L, false );
return 1;
}
- SetMusicPitch( state->music, lua_tonumber( L, -1 ) );
+ float pan = lua_tonumber( L, 1 );
+
+ SetMusicPitch( state->music, pan );
lua_pushboolean( L, true );
return 1;
diff --git a/src/shapes.c b/src/shapes.c
index d5f92f6..ef857ea 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -18,14 +18,13 @@ defining a font char white rectangle would allow drawing everything in a single
- Success return true
*/
int lshapesSetShapesTexture( lua_State *L ) {
- if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetShapesTexture( Texture2D texture, Rectangle source )" );
lua_pushboolean( L, false );
return 1;
}
- Rectangle source = uluaGetRectangle( L );
- lua_pop( L, 1 );
- size_t texId = lua_tointeger( L, -1 );
+ size_t texId = lua_tointeger( L, 1 );
+ Rectangle source = uluaGetRectangleIndex( L, 2 );
if ( !validSourceTexture( texId ) ) {
lua_pushboolean( L, false );
@@ -46,14 +45,13 @@ Draw a pixel
- Success return true
*/
int lshapesDrawPixel( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPixel( Vector2 pos, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- Vector2 pos = uluaGetVector2( L );
+ Vector2 pos = uluaGetVector2Index( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
DrawPixelV( pos, color );
lua_pushboolean( L, true );
@@ -70,18 +68,15 @@ Draw a line defining thickness
- Success return true
*/
int lshapesDrawLine( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float thickness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 endPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos = uluaGetVector2( L );
+ Vector2 startPos = uluaGetVector2Index( L, 1 );
+ Vector2 endPos = uluaGetVector2Index( L, 2 );
+ float thickness = lua_tonumber( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawLineEx( startPos, endPos, thickness, color );
lua_pushboolean( L, true );
@@ -98,18 +93,15 @@ Draw a line using cubic-bezier curves in-out
- Success return true
*/
int lshapesDrawLineBezier( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float thickness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 endPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos = uluaGetVector2( L );
+ Vector2 startPos = uluaGetVector2Index( L, 1 );
+ Vector2 endPos = uluaGetVector2Index( L, 2 );
+ float thickness = lua_tonumber( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawLineBezier( startPos, endPos, thickness, color );
lua_pushboolean( L, true );
@@ -126,20 +118,17 @@ Draw line using quadratic bezier curves with a control point
- Success return true
*/
int lshapesDrawLineBezierQuad( lua_State *L ) {
- if ( !lua_istable( L, -5 ) || !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
+ || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float thickness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 controlPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 endPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos = uluaGetVector2( L );
+ Vector2 startPos = uluaGetVector2Index( L, 1 );
+ Vector2 endPos = uluaGetVector2Index( L, 2 );
+ Vector2 controlPos = uluaGetVector2Index( L, 3 );
+ float thickness = lua_tonumber( L, 4 );
+ Color color = uluaGetColorIndex( L, 5 );
DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color );
lua_pushboolean( L, true );
@@ -156,23 +145,18 @@ Draw line using quadratic bezier curves with a control point
- Success return true
*/
int lshapesDrawLineBezierCubic( lua_State *L ) {
- if ( !lua_istable( L, -6 ) || !lua_istable( L, -5 ) || !lua_istable( L, -4 ) ||
- !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ||
+ !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float thickness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 endControlPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startControlPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 endPos = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos = uluaGetVector2( L );
+ Vector2 startPos = uluaGetVector2Index( L, 1 );
+ Vector2 endPos = uluaGetVector2Index( L, 2 );
+ Vector2 startControlPos = uluaGetVector2Index( L, 3 );
+ Vector2 endControlPos = uluaGetVector2Index( L, 4 );
+ float thickness = lua_tonumber( L, 5 );
+ Color color = uluaGetColorIndex( L, 6 );
DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color );
lua_pushboolean( L, true );
@@ -181,7 +165,7 @@ int lshapesDrawLineBezierCubic( lua_State *L ) {
}
/*
-> success = RL.DrawLineStrip( Vector2{} points, int pointsCount, Color color )
+> success = RL.DrawLineStrip( Vector2{} points, Color color )
Draw lines sequence
@@ -189,19 +173,18 @@ Draw lines sequence
- Success return true
*/
int lshapesDrawLineStrip( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
- TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineStrip( Vector2{} points, int pointsCount, Color color )" );
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawLineStrip( Vector2{} points, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int pointsCount = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
+ int pointsCount = uluaGetTableLenIndex( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
+
Vector2 points[ pointsCount ];
- int t = lua_gettop( L );
- int i = 0;
+ /* t = points index. */
+ int t = 1, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
@@ -225,16 +208,14 @@ Draw a color-filled circle
- Success return true
*/
int lshapesDrawCircle( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircle( Vector2 center, float radius, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ Color color = uluaGetColorIndex( L, 3 );
DrawCircleV( center, radius, color );
lua_pushboolean( L, true );
@@ -251,23 +232,18 @@ Draw a piece of a circle
- Success return true
*/
int lshapesDrawCircleSector( lua_State *L ) {
- if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
- !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
+ !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float endAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float startAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ float startAngle = lua_tonumber( L, 3 );
+ float endAngle = lua_tonumber( L, 4 );
+ int segments = lua_tointeger( L, 5 );
+ Color color = uluaGetColorIndex( L, 6 );
DrawCircleSector( center, radius, startAngle, endAngle, segments, color );
lua_pushboolean( L, true );
@@ -284,23 +260,18 @@ Draw circle sector outline
- Success return true
*/
int lshapesDrawCircleSectorLines( lua_State *L ) {
- if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
- !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
+ !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float endAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float startAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ float startAngle = lua_tonumber( L, 3 );
+ float endAngle = lua_tonumber( L, 4 );
+ int segments = lua_tointeger( L, 5 );
+ Color color = uluaGetColorIndex( L, 6 );
DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color );
lua_pushboolean( L, true );
@@ -317,18 +288,15 @@ Draw a gradient-filled circle
- Success return true
*/
int lshapesDrawCircleGradient( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )" );
lua_pushboolean( L, false );
return 1;
}
- Color color2 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color1 = uluaGetColor( L );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ Color color1 = uluaGetColorIndex( L, 3 );
+ Color color2 = uluaGetColorIndex( L, 4 );
DrawCircleGradient( center.x, center.y, radius, color1, color2 );
lua_pushboolean( L, true );
@@ -345,16 +313,14 @@ Draw circle outline
- Success return true
*/
int lshapesDrawCircleLines( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCircleLines( Vector2 center, float radius, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ Color color = uluaGetColorIndex( L, 3 );
DrawCircleLines( center.x, center.y, radius, color );
lua_pushboolean( L, true );
@@ -371,18 +337,15 @@ Draw ellipse
- Success return true
*/
int lshapesDrawEllipse( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float radiusV = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radiusH = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radiusH = lua_tonumber( L, 2 );
+ float radiusV = lua_tonumber( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawEllipse( center.x, center.y, radiusH, radiusV, color );
lua_pushboolean( L, true );
@@ -399,18 +362,15 @@ Draw ellipse outline
- Success return true
*/
int lshapesDrawEllipseLines( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float radiusV = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radiusH = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radiusH = lua_tonumber( L, 2 );
+ float radiusV = lua_tonumber( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawEllipseLines( center.x, center.y, radiusH, radiusV, color );
lua_pushboolean( L, true );
@@ -427,25 +387,19 @@ Draw ring
- Success return true
*/
int lshapesDrawRing( lua_State *L ) {
- if ( !lua_istable( L, -7 ) || !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
- !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ||
+ !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float endAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float startAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float outerRadius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float innerRadius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float innerRadius = lua_tonumber( L, 2 );
+ float outerRadius = lua_tonumber( L, 3 );
+ float startAngle = lua_tonumber( L, 4 );
+ float endAngle = lua_tonumber( L, 5 );
+ int segments = lua_tointeger( L, 6 );
+ Color color = uluaGetColorIndex( L, 7 );
DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
lua_pushboolean( L, true );
@@ -462,25 +416,19 @@ Draw ring outline
- Success return true
*/
int lshapesDrawRingLines( lua_State *L ) {
- if ( !lua_istable( L, -7 ) || !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
- !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ||
+ !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float endAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float startAngle = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float outerRadius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float innerRadius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float innerRadius = lua_tonumber( L, 2 );
+ float outerRadius = lua_tonumber( L, 3 );
+ float startAngle = lua_tonumber( L, 4 );
+ float endAngle = lua_tonumber( L, 5 );
+ int segments = lua_tointeger( L, 6 );
+ Color color = uluaGetColorIndex( L, 7 );
DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color );
lua_pushboolean( L, true );
@@ -497,14 +445,13 @@ Draw a color-filled rectangle
- Success return true
*/
int lshapesDrawRectangle( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangle( Rectangle rec, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
DrawRectangleRec( rect, color );
lua_pushboolean( L, true );
@@ -521,18 +468,15 @@ Draw a color-filled rectangle with pro parameters
- Success return true
*/
int lshapesDrawRectanglePro( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float rotation = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 origin = uluaGetVector2( L );
- lua_pop( L, 1 );
- Rectangle rec = uluaGetRectangle( L );
+ Rectangle rec = uluaGetRectangleIndex( L, 1 );
+ Vector2 origin = uluaGetVector2Index( L, 2 );
+ float rotation = lua_tonumber( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawRectanglePro( rec, origin, rotation, color );
lua_pushboolean( L, true );
@@ -549,16 +493,14 @@ Draw a vertical-gradient-filled rectangle
- Success return true
*/
int lshapesDrawRectangleGradientV( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )" );
lua_pushboolean( L, false );
return 1;
}
- Color color2 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color1 = uluaGetColor( L );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ Color color1 = uluaGetColorIndex( L, 2 );
+ Color color2 = uluaGetColorIndex( L, 3 );
DrawRectangleGradientV( rect.x, rect.y, rect.width, rect.height, color1, color2 );
lua_pushboolean( L, true );
@@ -575,16 +517,14 @@ Draw a horizontal-gradient-filled rectangle
- Success return true
*/
int lshapesDrawRectangleGradientH( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )" );
lua_pushboolean( L, false );
return 1;
}
- Color color2 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color1 = uluaGetColor( L );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ Color color1 = uluaGetColorIndex( L, 2 );
+ Color color2 = uluaGetColorIndex( L, 3 );
DrawRectangleGradientH( rect.x, rect.y, rect.width, rect.height, color1, color2 );
lua_pushboolean( L, true );
@@ -601,20 +541,17 @@ Draw a gradient-filled rectangle with custom vertex colors
- Success return true
*/
int lshapesDrawRectangleGradientEx( lua_State *L ) {
- if ( !lua_istable( L, -5 ) || !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 )
+ || !lua_istable( L, 4 ) || !lua_istable( L, 5 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )" );
lua_pushboolean( L, false );
return 1;
}
- Color color4 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color3 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color2 = uluaGetColor( L );
- lua_pop( L, 1 );
- Color color1 = uluaGetColor( L );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ Color color1 = uluaGetColorIndex( L, 2 );
+ Color color2 = uluaGetColorIndex( L, 3 );
+ Color color3 = uluaGetColorIndex( L, 4 );
+ Color color4 = uluaGetColorIndex( L, 5 );
DrawRectangleGradientEx( rect, color1, color2, color3, color4 );
lua_pushboolean( L, true );
@@ -631,14 +568,13 @@ Draw rectangle outline
- Success return true
*/
int lshapesDrawRectangleLines( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleLines( Rectangle rec, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
DrawRectangleLines( rect.x, rect.y, rect.width, rect.height, color );
lua_pushboolean( L, true );
@@ -655,16 +591,14 @@ Draw rectangle outline with extended parameters
- Success return true
*/
int lshapesDrawRectangleLinesEx( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int lineThick = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ int lineThick = lua_tointeger( L, 2 );
+ Color color = uluaGetColorIndex( L, 3 );
DrawRectangleLinesEx( rect, lineThick, color );
lua_pushboolean( L, true );
@@ -681,18 +615,15 @@ Draw rectangle with rounded edges
- Success return true
*/
int lshapesDrawRectangleRounded( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float roundness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ float roundness = lua_tonumber( L, 2 );
+ int segments = lua_tointeger( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawRectangleRounded( rect, roundness, segments, color );
lua_pushboolean( L, true );
@@ -709,20 +640,17 @@ Draw rectangle with rounded edges outline
- Success return true
*/
int lshapesDrawRectangleRoundedLines( lua_State *L ) {
- if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
+ || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int lineThick = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- int segments = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- float roundness = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Rectangle rect = uluaGetRectangle( L );
+ Rectangle rect = uluaGetRectangleIndex( L, 1 );
+ float roundness = lua_tonumber( L, 2 );
+ int segments = lua_tointeger( L, 3 );
+ int lineThick = lua_tointeger( L, 4 );
+ Color color = uluaGetColorIndex( L, 5 );
DrawRectangleRoundedLines( rect, roundness, segments, lineThick, color );
lua_pushboolean( L, true );
@@ -739,18 +667,15 @@ Draw a color-filled triangle ( Vertex in counter-clockwise order! )
- Success return true
*/
int lshapesDrawTriangle( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- Vector2 v3 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 v2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 v1 = uluaGetVector2( L );
+ Vector2 v1 = uluaGetVector2Index( L, 1 );
+ Vector2 v2 = uluaGetVector2Index( L, 2 );
+ Vector2 v3 = uluaGetVector2Index( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawTriangle( v1, v2, v3, color );
lua_pushboolean( L, true );
@@ -767,18 +692,15 @@ Draw triangle outline ( Vertex in counter-clockwise order! )
- Success return true
*/
int lshapesDrawTriangleLines( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- Vector2 v3 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 v2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 v1 = uluaGetVector2( L );
+ Vector2 v1 = uluaGetVector2Index( L, 1 );
+ Vector2 v2 = uluaGetVector2Index( L, 2 );
+ Vector2 v3 = uluaGetVector2Index( L, 3 );
+ Color color = uluaGetColorIndex( L, 4 );
DrawTriangleLines( v1, v2, v3, color );
lua_pushboolean( L, true );
@@ -787,7 +709,7 @@ int lshapesDrawTriangleLines( lua_State *L ) {
}
/*
-> success = RL.DrawTriangleFan( Vector2{} points, int pointsCount, Color color )
+> success = RL.DrawTriangleFan( Vector2{} points, Color color )
Draw a triangle fan defined by points ( first vertex is the center )
@@ -795,19 +717,18 @@ Draw a triangle fan defined by points ( first vertex is the center )
- Success return true
*/
int lshapesDrawTriangleFan( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
- TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleFan( Vector2{} points, int pointsCount, Color color )" );
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleFan( Vector2{} points, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int pointsCount = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
+ int pointsCount = uluaGetTableLenIndex( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
+
Vector2 points[ pointsCount ];
- int t = lua_gettop( L );
- int i = 0;
+ /* t = points index. */
+ int t = 1, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
@@ -823,7 +744,7 @@ int lshapesDrawTriangleFan( lua_State *L ) {
}
/*
-> success = RL.DrawTriangleStrip( Vector2{} points, int pointsCount, Color color )
+> success = RL.DrawTriangleStrip( Vector2{} points, Color color )
Draw a triangle strip defined by points
@@ -831,19 +752,18 @@ Draw a triangle strip defined by points
- Success return true
*/
int lshapesDrawTriangleStrip( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
- TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleStrip( Vector2{} points, int pointsCount, Color color )" );
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTriangleStrip( Vector2{} points, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- int pointsCount = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
+ int pointsCount = uluaGetTableLenIndex( L, 1 );
+ Color color = uluaGetColorIndex( L, 2 );
+
Vector2 points[ pointsCount ];
- int t = lua_gettop( L );
- int i = 0;
+ /* t = points index. */
+ int t = 1, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
@@ -867,20 +787,17 @@ Draw a regular polygon ( Vector version )
- Success return true
*/
int lshapesDrawPoly( lua_State *L ) {
- if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
+ || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float rotation = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- int sides = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ int sides = lua_tointeger( L, 2 );
+ float radius = lua_tonumber( L, 3 );
+ float rotation = lua_tonumber( L, 4 );
+ Color color = uluaGetColorIndex( L, 5 );
DrawPoly( center, sides, radius, rotation, color );
lua_pushboolean( L, true );
@@ -897,20 +814,17 @@ Draw a polygon outline of n sides
- Success return true
*/
int lshapesDrawPolyLines( lua_State *L ) {
- if ( !lua_istable( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 )
+ || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float rotation = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- int sides = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ int sides = lua_tointeger( L, 2 );
+ float radius = lua_tonumber( L, 3 );
+ float rotation = lua_tonumber( L, 4 );
+ Color color = uluaGetColorIndex( L, 5 );
DrawPolyLines( center, sides, radius, rotation, color );
lua_pushboolean( L, true );
@@ -927,23 +841,18 @@ Draw a polygon outline of n sides with extended parameters
- Success return true
*/
int lshapesDrawPolyLinesEx( lua_State *L ) {
- if ( !lua_istable( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) ||
- !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ||
+ !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )" );
lua_pushboolean( L, false );
return 1;
}
- Color color = uluaGetColor( L );
- lua_pop( L, 1 );
- float lineThick = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float rotation = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- int sides = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ int sides = lua_tointeger( L, 2 );
+ float radius = lua_tonumber( L, 3 );
+ float rotation = lua_tonumber( L, 4 );
+ float lineThick = lua_tonumber( L, 5 );
+ Color color = uluaGetColorIndex( L, 6 );
DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color );
lua_pushboolean( L, true );
@@ -964,14 +873,13 @@ Check collision between two rectangles
- Success return bool
*/
int lshapesCheckCollisionRecs( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionRecs( Rectangle rec1, Rectangle rec2 )" );
lua_pushnil( L );
return 1;
}
- Rectangle rect1 = uluaGetRectangle( L );
- lua_pop( L, 1 );
- Rectangle rect2 = uluaGetRectangle( L );
+ Rectangle rect1 = uluaGetRectangleIndex( L, 1 );
+ Rectangle rect2 = uluaGetRectangleIndex( L, 2 );
lua_pushboolean( L, CheckCollisionRecs( rect1, rect2 ) );
@@ -987,18 +895,15 @@ Check collision between two circles
- Success return bool
*/
int lshapesCheckCollisionCircles( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, float radius2 )" );
lua_pushnil( L );
return 1;
}
- float radius2 = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- float radius1 = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center1 = uluaGetVector2( L );
+ Vector2 center1 = uluaGetVector2Index( L, 1 );
+ float radius1 = lua_tonumber( L, 2 );
+ Vector2 center2 = uluaGetVector2Index( L, 3 );
+ float radius2 = lua_tonumber( L, 4 );
lua_pushboolean( L, CheckCollisionCircles( center1, radius1, center2, radius2 ) );
@@ -1014,16 +919,14 @@ Check collision between circle and rectangle
- Success return bool
*/
int lshapesCheckCollisionCircleRec( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionCircleRec( Vector2 center, float radius, Rectangle rec )" );
lua_pushnil( L );
return 1;
}
- Rectangle rec = uluaGetRectangle( L );
- lua_pop( L, 1 );
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
+ Vector2 center = uluaGetVector2Index( L, 1 );
+ float radius = lua_tonumber( L, 2 );
+ Rectangle rec = uluaGetRectangleIndex( L, 3 );
lua_pushboolean( L, CheckCollisionCircleRec( center, radius, rec ) );
@@ -1039,14 +942,13 @@ Check if point is inside rectangle
- Success return bool
*/
int lshapesCheckCollisionPointRec( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )" );
lua_pushnil( L );
return 1;
}
- Rectangle rec = uluaGetRectangle( L );
- lua_pop( L, 1 );
- Vector2 point = uluaGetVector2( L );
+ Vector2 point = uluaGetVector2Index( L, 1 );
+ Rectangle rec = uluaGetRectangleIndex( L, 2 );
lua_pushboolean( L, CheckCollisionPointRec( point, rec ) );
@@ -1062,16 +964,14 @@ Check if point is inside circle
- Success return bool
*/
int lshapesCheckCollisionPointCircle( lua_State *L ) {
- if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointCircle( Vector2 point, Vector2 center, float radius )" );
lua_pushnil( L );
return 1;
}
- float radius = lua_tonumber( L, -1 );
- lua_pop( L, 1 );
- Vector2 center = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 point = uluaGetVector2( L );
+ Vector2 point = uluaGetVector2Index( L, 1 );
+ Vector2 center = uluaGetVector2Index( L, 2 );
+ float radius = lua_tonumber( L, 3 );
lua_pushboolean( L, CheckCollisionPointCircle( point, center, radius ) );
@@ -1087,18 +987,15 @@ Check if point is inside a triangle
- Success return bool
*/
int lshapesCheckCollisionPointTriangle( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointTriangle( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 )" );
lua_pushnil( L );
return 1;
}
- Vector2 p3 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 p2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 p1 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 point = uluaGetVector2( L );
+ Vector2 point = uluaGetVector2Index( L, 1 );
+ Vector2 p1 = uluaGetVector2Index( L, 2 );
+ Vector2 p2 = uluaGetVector2Index( L, 3 );
+ Vector2 p3 = uluaGetVector2Index( L, 4 );
lua_pushboolean( L, CheckCollisionPointTriangle( point, p1, p2, p3 ) );
@@ -1114,16 +1011,17 @@ Check if point is within a polygon described by array of vertices
- Success return bool
*/
int lshapesCheckCollisionPointPoly( lua_State *L ) {
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )" );
lua_pushnil( L );
return 1;
}
- int pointCount = uluaGetTableLen( L );
+ Vector2 point = uluaGetVector2Index( L, 1 );
+ int pointCount = uluaGetTableLenIndex( L, 2 );
Vector2 points[ pointCount ];
- int t = lua_gettop( L );
- int i = 0;
+ /* t = points index. */
+ int t = 2, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
@@ -1131,9 +1029,6 @@ int lshapesCheckCollisionPointPoly( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
- lua_pop( L, 1 );
-
- Vector2 point = uluaGetVector2( L );
lua_pushboolean( L, CheckCollisionPointPoly( point, points, pointCount ) );
@@ -1149,18 +1044,15 @@ Check the collision between two lines defined by two points each, returns collis
- Success return bool, Vector2
*/
int lshapesCheckCollisionLines( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )" );
lua_pushnil( L );
return 1;
}
- Vector2 endPos2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 endPos1 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 startPos1 = uluaGetVector2( L );
+ Vector2 startPos1 = uluaGetVector2Index( L, 1 );
+ Vector2 endPos1 = uluaGetVector2Index( L, 2 );
+ Vector2 startPos2 = uluaGetVector2Index( L, 3 );
+ Vector2 endPos2 = uluaGetVector2Index( L, 4 );
Vector2 colPoint = { 0, 0 };
@@ -1179,18 +1071,15 @@ Check if point belongs to line created between two points [p1] and [p2] with def
- Success return bool
*/
int lshapesCheckCollisionPointLine( lua_State *L ) {
- if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CheckCollisionPointLine( Vector2 point, Vector2 p1, Vector2 p2, int threshold )" );
lua_pushnil( L );
return 1;
}
- int threshold = lua_tointeger( L, -1 );
- lua_pop( L, 1 );
- Vector2 p2 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 p1 = uluaGetVector2( L );
- lua_pop( L, 1 );
- Vector2 point = uluaGetVector2( L );
+ Vector2 point = uluaGetVector2Index( L, 1 );
+ Vector2 p1 = uluaGetVector2Index( L, 2 );
+ Vector2 p2 = uluaGetVector2Index( L, 3 );
+ int threshold = lua_tointeger( L, 4 );
lua_pushboolean( L, CheckCollisionPointLine( point, p1, p2, threshold ) );
@@ -1206,15 +1095,13 @@ Get collision rectangle for two rectangles collision
- Success return Rectangle
*/
int lshapesGetCollisionRec( lua_State *L ) {
- /* Rectangle rec1, Rectangle rec2 */
- if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetCollisionRec( Rectangle rec1, Rectangle rec2 )" );
lua_pushnil( L );
return 1;
}
- Rectangle rec2 = uluaGetRectangle( L );
- lua_pop( L, 1 );
- Rectangle rec1 = uluaGetRectangle( L );
+ Rectangle rec1 = uluaGetRectangleIndex( L, 1 );
+ Rectangle rec2 = uluaGetRectangleIndex( L, 2 );
uluaPushRectangle( L, GetCollisionRec( rec1, rec2 ) );
diff --git a/src/textures.c b/src/textures.c
index 1936c5e..1797bc7 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -154,7 +154,6 @@ int ltexturesLoadImage( lua_State *L ) {
int i = newImage();
*state->images[i] = LoadImage( lua_tostring( L, 1 ) );
lua_pushinteger( L, i );
-
return 1;
}
else {