summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2024-03-17 10:38:30 +0200
committerjussi2024-03-17 10:38:30 +0200
commitae1d0b65f16b24f2e0db39cb8baef4af57b2a12f (patch)
tree80358810635da19821bdb38ece2098c2dd48f1ff /src
parentca238975dc63d2dddcd2b17ad627bedc95dd158c (diff)
downloadreilua-enhanced-ae1d0b65f16b24f2e0db39cb8baef4af57b2a12f.tar.gz
reilua-enhanced-ae1d0b65f16b24f2e0db39cb8baef4af57b2a12f.tar.bz2
reilua-enhanced-ae1d0b65f16b24f2e0db39cb8baef4af57b2a12f.zip
Round and pubsub lib.
Diffstat (limited to 'src')
-rw-r--r--src/core.c4
-rw-r--r--src/lua_core.c1
-rw-r--r--src/rmath.c15
3 files changed, 18 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index d985701..b839937 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2096,7 +2096,7 @@ int lcoreGetAutomationEventListCount( lua_State* L ) {
/*
> event = RL.GetAutomationEvent( AutomationEventList list, int index )
-Get automation event from automation event list
+Get automation event from automation event list. Return as lightuserdata
- Failure return nil
- Success return AutomationEvent
@@ -2106,7 +2106,7 @@ int lcoreGetAutomationEvent( lua_State* L ) {
int index = luaL_checkinteger( L, 2 );
if ( 0 <= index && index < list->count ) {
- uluaPushAutomationEvent( L, list->events[ index ] );
+ lua_pushlightuserdata( L, &list->events[ index ] );
}
else {
TraceLog( LOG_WARNING, "GetAutomationEvent index %d out of bounds", index );
diff --git a/src/lua_core.c b/src/lua_core.c
index 0c15c18..d632897 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1893,6 +1893,7 @@ void luaRegister() {
/* Math. */
/* Utils. */
+ assingGlobalFunction( "Round", lmathRound );
assingGlobalFunction( "Clamp", lmathClamp );
assingGlobalFunction( "Lerp", lmathLerp );
assingGlobalFunction( "Normalize", lmathNormalize );
diff --git a/src/rmath.c b/src/rmath.c
index 2b05c7e..7617d45 100644
--- a/src/rmath.c
+++ b/src/rmath.c
@@ -16,6 +16,21 @@ inline int imax( int a, int b ) {
*/
/*
+> result = RL.Round( float value )
+
+Round float value
+
+- Success return float
+*/
+int lmathRound( lua_State* L ) {
+ float value = luaL_checknumber( L, 1 );
+
+ lua_pushnumber( L, round( value ) );
+
+ return 1;
+}
+
+/*
> result = RL.Clamp( float value, float min, float max )
Clamp float value