summaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
authorjussi2024-11-21 00:11:31 +0200
committerjussi2024-11-21 00:11:31 +0200
commit4c0eb17a9c234bfee73af408faa38e38f2e450d9 (patch)
tree4aea4fe804a63ed13a1d092aada0ba5925dcf05f /src/core.c
parent479726a5e468a2f4d0f9337f082889082e535bfb (diff)
downloadreilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.gz
reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.bz2
reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.zip
New raylib 5.5 functions.
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c184
1 files changed, 158 insertions, 26 deletions
diff --git a/src/core.c b/src/core.c
index 3473251..c3c07c5 100644
--- a/src/core.c
+++ b/src/core.c
@@ -560,6 +560,19 @@ int lcoreGetClipboardText( lua_State* L ) {
}
/*
+> image = RL.GetClipboardImage()
+
+Get clipboard image content
+
+- Success return Image
+*/
+int lcoreGetClipboardImage( lua_State* L ) {
+ uluaPushImage( L, GetClipboardImage() );
+
+ return 1;
+}
+
+/*
> RL.EnableEventWaiting()
Enable waiting for events on EndDrawing(), no automatic event polling
@@ -1783,6 +1796,60 @@ int lcoreGetApplicationDirectory( lua_State* L ) {
}
/*
+> success = RL.MakeDirectory( string dirPath )
+
+Create directories (including full path requested), returns 0 on success
+
+- Success return int
+*/
+int lcoreMakeDirectory( lua_State* L ) {
+ const char *dirPath = luaL_checkstring( L, 1 );
+
+ lua_pushinteger( L, MakeDirectory( dirPath ) );
+
+ return 1;
+}
+
+/*
+> success = RL.ChangeDirectory( string directory )
+
+Change working directory, return true on success
+
+- Success return bool
+*/
+int lcoreChangeDirectory( lua_State* L ) {
+ lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> isFile = RL.IsPathFile( string path )
+
+Check if a given path is a file or a directory
+
+- Success return bool
+*/
+int lcoreIsPathFile( lua_State* L ) {
+ lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> isValid = RL.IsFileNameValid( string fileName )
+
+Check if fileName is valid for the platform/OS
+
+- Success return bool
+*/
+int lcoreIsFileNameValid( lua_State* L ) {
+ lua_pushboolean( L, IsFileNameValid( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
> fileNames = RL.LoadDirectoryFiles( string dirPath )
Load directory filepaths
@@ -1832,32 +1899,6 @@ int lcoreLoadDirectoryFilesEx( lua_State* L ) {
}
/*
-> success = RL.ChangeDirectory( string directory )
-
-Change working directory, return true on success
-
-- Success return bool
-*/
-int lcoreChangeDirectory( lua_State* L ) {
- lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> isFile = RL.IsPathFile( string path )
-
-Check if a given path is a file or a directory
-
-- Success return bool
-*/
-int lcoreIsPathFile( lua_State* L ) {
- lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
> iSFileDropped = RL.IsFileDropped()
Check if a file has been dropped into window
@@ -1998,6 +2039,81 @@ int lcoreDecodeDataBase64( lua_State* L ) {
}
/*
+> code = RL.ComputeCRC32( Buffer data )
+
+Compute CRC32 hash code. Note! Buffer should be type BUFFER_UNSIGNED_CHAR
+
+- Failure return false
+- Success return int
+*/
+int lcoreComputeCRC32( lua_State* L ) {
+ Buffer* buffer = uluaGetBuffer( L, 1 );
+
+ if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
+ lua_pushinteger( L, ComputeCRC32( buffer->data, buffer->size ) );
+ }
+ else {
+ lua_pushboolean( L, false );
+ }
+
+ return 1;
+}
+
+/*
+> code = RL.ComputeMD5( Buffer data )
+
+Compute MD5 hash code, returns static int[4] (16 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
+
+- Failure return false
+- Success return int{4}
+*/
+int lcoreComputeMD5( lua_State* L ) {
+ Buffer* buffer = uluaGetBuffer( L, 1 );
+
+ if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
+ unsigned int* code = ComputeMD5( buffer->data, buffer->size );
+ lua_createtable( L, 4, 0 );
+
+ for ( unsigned int i = 0; i < 4; i++ ) {
+ lua_pushinteger( L, code[i] );
+ lua_rawseti( L, -2, i + 1 );
+ }
+ }
+ else {
+ lua_pushboolean( L, false );
+ }
+
+ return 1;
+}
+
+/*
+> code = RL.ComputeSHA1( Buffer data )
+
+Compute SHA1 hash code, returns static int[5] (20 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
+
+- Failure return false
+- Success return int{5}
+*/
+int lcoreComputeSHA1( lua_State* L ) {
+ Buffer* buffer = uluaGetBuffer( L, 1 );
+
+ if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
+ unsigned int* code = ComputeSHA1( buffer->data, buffer->size );
+ lua_createtable( L, 5, 0 );
+
+ for ( unsigned int i = 0; i < 5; i++ ) {
+ lua_pushinteger( L, code[i] );
+ lua_rawseti( L, -2, i + 1 );
+ }
+ }
+ else {
+ lua_pushboolean( L, false );
+ }
+
+ return 1;
+}
+
+/*
## Core - Automation events functionality
*/
@@ -2491,6 +2607,22 @@ int lcoreSetGamepadMappings( lua_State* L ) {
}
/*
+> RL.SetGamepadVibration( int gamepad, float leftMotor, float rightMotor, float duration )
+
+Set gamepad vibration for both motors (duration in seconds)
+*/
+int lcoreSetGamepadVibration( lua_State* L ) {
+ int gamepad = luaL_checkinteger( L, 1 );
+ float leftMotor = luaL_checknumber( L, 2 );
+ float rightMotor = luaL_checknumber( L, 2 );
+ float duration = luaL_checknumber( L, 2 );
+
+ SetGamepadVibration( gamepad, leftMotor, rightMotor, duration );
+
+ return 0;
+}
+
+/*
## Core - Input-related functions: mouse
*/