Automation events.
This commit is contained in:
106
API.md
106
API.md
@@ -4516,6 +4516,112 @@ Decode Base64 string data
|
||||
|
||||
---
|
||||
|
||||
## Core - Automation events functionality
|
||||
|
||||
---
|
||||
|
||||
> eventList = RL.LoadAutomationEventList( string|nil fileName )
|
||||
|
||||
Load automation events list from file, nil for empty list, capacity = MAX_AUTOMATION_EVENTS
|
||||
|
||||
- Success return AutomationEventList
|
||||
|
||||
---
|
||||
|
||||
> RL.UnloadAutomationEventList( AutomationEventList list )
|
||||
|
||||
Unload automation events list from file
|
||||
|
||||
---
|
||||
|
||||
> success = RL.ExportAutomationEventList( string fileName )
|
||||
|
||||
Export automation events list as text file
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> RL.SetAutomationEventList( AutomationEventList list )
|
||||
|
||||
Set automation event list to record to
|
||||
|
||||
---
|
||||
|
||||
> RL.SetAutomationEventBaseFrame( int frame )
|
||||
|
||||
Set automation event internal base frame to start recording
|
||||
|
||||
---
|
||||
|
||||
> RL.StartAutomationEventRecording()
|
||||
|
||||
Start recording automation events (AutomationEventList must be set)
|
||||
|
||||
---
|
||||
|
||||
> RL.StopAutomationEventRecording()
|
||||
|
||||
Stop recording automation events
|
||||
|
||||
---
|
||||
|
||||
> RL.PlayAutomationEvent( AutomationEvent event )
|
||||
|
||||
Play a recorded automation event
|
||||
|
||||
---
|
||||
|
||||
> capacity = RL.GetAutomationEventListCapacity( AutomationEventList list )
|
||||
|
||||
Get automation event list capacity
|
||||
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> count = RL.GetAutomationEventListCount( AutomationEventList list )
|
||||
|
||||
Get automation event list count
|
||||
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> event = RL.GetAutomationEvent( AutomationEventList list, int index )
|
||||
|
||||
Get automation event from automation event list
|
||||
|
||||
- Failure return nil
|
||||
- Success return AutomationEvent
|
||||
|
||||
---
|
||||
|
||||
> frame = RL.GetAutomationEventFrame( AutomationEvent event )
|
||||
|
||||
Get automation event frame
|
||||
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> type = RL.GetAutomationEventType( AutomationEvent event )
|
||||
|
||||
Get automation event type
|
||||
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> params = RL.GetAutomationEventParams( AutomationEvent event )
|
||||
|
||||
Get automation event params
|
||||
|
||||
- Success return int{}
|
||||
|
||||
---
|
||||
|
||||
## Core - Input-related functions: keyboard
|
||||
|
||||
---
|
||||
|
||||
@@ -1978,6 +1978,87 @@ function RL.EncodeDataBase64( data ) end
|
||||
---@return any outputSize
|
||||
function RL.DecodeDataBase64( data ) end
|
||||
|
||||
-- Core - Automation events functionality
|
||||
|
||||
---Load automation events list from file, nil for empty list, capacity = MAX_AUTOMATION_EVENTS
|
||||
---- Success return AutomationEventList
|
||||
---@param fileName any
|
||||
---@return any eventList
|
||||
function RL.LoadAutomationEventList( fileName ) end
|
||||
|
||||
---Unload automation events list from file
|
||||
---@param list any
|
||||
---@return any RL.UnloadAutomationEventList
|
||||
function RL.UnloadAutomationEventList( list ) end
|
||||
|
||||
---Export automation events list as text file
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param fileName string
|
||||
---@return any success
|
||||
function RL.ExportAutomationEventList( fileName ) end
|
||||
|
||||
---Set automation event list to record to
|
||||
---@param list any
|
||||
---@return any RL.SetAutomationEventList
|
||||
function RL.SetAutomationEventList( list ) end
|
||||
|
||||
---Set automation event internal base frame to start recording
|
||||
---@param frame integer
|
||||
---@return any RL.SetAutomationEventBaseFrame
|
||||
function RL.SetAutomationEventBaseFrame( frame ) end
|
||||
|
||||
---Start recording automation events (AutomationEventList must be set)
|
||||
---@return any RL.StartAutomationEventRecording
|
||||
function RL.StartAutomationEventRecording() end
|
||||
|
||||
---Stop recording automation events
|
||||
---@return any RL.StopAutomationEventRecording
|
||||
function RL.StopAutomationEventRecording() end
|
||||
|
||||
---Play a recorded automation event
|
||||
---@param event any
|
||||
---@return any RL.PlayAutomationEvent
|
||||
function RL.PlayAutomationEvent( event ) end
|
||||
|
||||
---Get automation event list capacity
|
||||
---- Success return int
|
||||
---@param list any
|
||||
---@return any capacity
|
||||
function RL.GetAutomationEventListCapacity( list ) end
|
||||
|
||||
---Get automation event list count
|
||||
---- Success return int
|
||||
---@param list any
|
||||
---@return any count
|
||||
function RL.GetAutomationEventListCount( list ) end
|
||||
|
||||
---Get automation event from automation event list
|
||||
---- Failure return nil
|
||||
---- Success return AutomationEvent
|
||||
---@param list any
|
||||
---@param index integer
|
||||
---@return any event
|
||||
function RL.GetAutomationEvent( list, index ) end
|
||||
|
||||
---Get automation event frame
|
||||
---- Success return int
|
||||
---@param event any
|
||||
---@return any frame
|
||||
function RL.GetAutomationEventFrame( event ) end
|
||||
|
||||
---Get automation event type
|
||||
---- Success return int
|
||||
---@param event any
|
||||
---@return any type
|
||||
function RL.GetAutomationEventType( event ) end
|
||||
|
||||
---Get automation event params
|
||||
---- Success return int{}
|
||||
---@param event any
|
||||
---@return any params
|
||||
function RL.GetAutomationEventParams( event ) end
|
||||
|
||||
-- Core - Input-related functions: keyboard
|
||||
|
||||
---Detect if a key has been pressed once
|
||||
|
||||
@@ -9,6 +9,7 @@ KEY CHANGES:
|
||||
- ADDED: apiScanner.lua for searching unimplemented functions from raylib.
|
||||
- ADDED & CHANGE: ImageText. ImageTextEx is now equivalent to raylib function and old ImageText.
|
||||
- ADDED & CHANGE: MeasureText. MeasureTextEx is now equivalent to raylib function and old MeasureText.
|
||||
- ADDED Automation events.
|
||||
|
||||
DETAILED CHANGES:
|
||||
- ADDED: GetBufferElementSize and GetBufferLength.
|
||||
|
||||
2
devnotes
2
devnotes
@@ -10,8 +10,6 @@ Backlog {
|
||||
* Haptic functions.
|
||||
* Audio
|
||||
* AudioStream.
|
||||
* Core
|
||||
* Automation events functionality.
|
||||
* Models
|
||||
* Mesh bone weight management?
|
||||
|
||||
|
||||
97
examples/automation_events/main.lua
Normal file
97
examples/automation_events/main.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||
|
||||
Vec2 = require( "vector2" )
|
||||
|
||||
local eventList = nil
|
||||
local evenRecording = false
|
||||
local eventPlaying = false
|
||||
local frameCounter = 0
|
||||
local playFrameCounter = 0
|
||||
local currentPlayFrame = 0
|
||||
local player = {
|
||||
pos = Vec2:new( 160, 200 ),
|
||||
speed = 100.0,
|
||||
}
|
||||
|
||||
function RL.init()
|
||||
RL.SetWindowTitle( "Automation Events" )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
RL.SetTextLineSpacing( 25 )
|
||||
|
||||
eventList = RL.LoadAutomationEventList( nil )
|
||||
RL.SetAutomationEventList( eventList )
|
||||
end
|
||||
|
||||
function RL.update( delta )
|
||||
local moveDir = Vec2:new()
|
||||
|
||||
if RL.IsKeyDown( RL.KEY_RIGHT ) then
|
||||
moveDir.x = 1
|
||||
elseif RL.IsKeyDown( RL.KEY_LEFT ) then
|
||||
moveDir.x = -1
|
||||
end
|
||||
|
||||
if RL.IsKeyDown( RL.KEY_DOWN ) then
|
||||
moveDir.y = 1
|
||||
elseif RL.IsKeyDown( RL.KEY_UP ) then
|
||||
moveDir.y = -1
|
||||
end
|
||||
|
||||
player.pos:addEq( moveDir:scale( player.speed * delta ) )
|
||||
|
||||
-- Events.
|
||||
|
||||
if RL.IsKeyPressed( RL.KEY_S ) then
|
||||
evenRecording = not evenRecording
|
||||
|
||||
if evenRecording then
|
||||
RL.StartAutomationEventRecording()
|
||||
else
|
||||
RL.StopAutomationEventRecording()
|
||||
end
|
||||
end
|
||||
if RL.IsKeyPressed( RL.KEY_A ) then
|
||||
eventPlaying = not eventPlaying
|
||||
evenRecording = false
|
||||
playFrameCounter = 0
|
||||
currentPlayFrame = 0
|
||||
end
|
||||
|
||||
if eventPlaying then
|
||||
while playFrameCounter == RL.GetAutomationEventFrame( RL.GetAutomationEvent( eventList, currentPlayFrame ) ) do
|
||||
RL.TraceLog( RL.LOG_INFO, "playFrameCounter: "..playFrameCounter.."\tcurrentPlayFrame: "..currentPlayFrame )
|
||||
|
||||
RL.PlayAutomationEvent( RL.GetAutomationEvent( eventList, currentPlayFrame ) )
|
||||
currentPlayFrame = currentPlayFrame + 1
|
||||
|
||||
if currentPlayFrame == RL.GetAutomationEventListCount( eventList ) then
|
||||
eventPlaying = false
|
||||
currentPlayFrame = 0
|
||||
playFrameCounter = 0
|
||||
|
||||
RL.TraceLog( RL.LOG_INFO, "FINISH PLAYING!" )
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
playFrameCounter = playFrameCounter + 1
|
||||
end
|
||||
end
|
||||
|
||||
function RL.draw()
|
||||
RL.ClearBackground( RL.RAYWHITE )
|
||||
RL.DrawCircle( player.pos, 8.0, RL.BLUE )
|
||||
|
||||
local text = "Toggle recording: S\nToggle play: A\n"
|
||||
local textColor = RL.GREEN
|
||||
|
||||
if evenRecording then
|
||||
text = text.."Recording"
|
||||
textColor = RL.RED
|
||||
elseif eventPlaying then
|
||||
text = text.."Playing"
|
||||
textColor = RL.BLUE
|
||||
end
|
||||
|
||||
RL.DrawText( text, { 20, 20 }, 20, textColor )
|
||||
end
|
||||
@@ -153,4 +153,32 @@ function Quaternion:transform( mat )
|
||||
return Quaternion:new( RL.QuaternionTransform( self, mat ) )
|
||||
end
|
||||
|
||||
function Quaternion:addEq( q2 )
|
||||
self.x = self.x + q2.x
|
||||
self.y = self.y + q2.y
|
||||
self.z = self.z + q2.z
|
||||
self.w = self.w + q2.w
|
||||
end
|
||||
|
||||
function Quaternion:subEq( q2 )
|
||||
self.x = self.x - q2.x
|
||||
self.y = self.y - q2.y
|
||||
self.z = self.z - q2.z
|
||||
self.w = self.w - q2.w
|
||||
end
|
||||
|
||||
function Quaternion:mulEq( q2 )
|
||||
self.x = self.x * q2.x
|
||||
self.y = self.y * q2.y
|
||||
self.z = self.z * q2.z
|
||||
self.w = self.w * q2.w
|
||||
end
|
||||
|
||||
function Quaternion:divEq( q2 )
|
||||
self.x = self.x / q2.x
|
||||
self.y = self.y / q2.y
|
||||
self.z = self.z / q2.z
|
||||
self.w = self.w / q2.w
|
||||
end
|
||||
|
||||
return Quaternion
|
||||
|
||||
@@ -181,4 +181,24 @@ function Vector2:equals( v2 )
|
||||
return RL.Vector2Equals( self, v2 )
|
||||
end
|
||||
|
||||
function Vector2:addEq( v2 )
|
||||
self.x = self.x + v2.x
|
||||
self.y = self.y + v2.y
|
||||
end
|
||||
|
||||
function Vector2:subEq( v2 )
|
||||
self.x = self.x - v2.x
|
||||
self.y = self.y - v2.y
|
||||
end
|
||||
|
||||
function Vector2:mulEq( v2 )
|
||||
self.x = self.x * v2.x
|
||||
self.y = self.y * v2.y
|
||||
end
|
||||
|
||||
function Vector2:divEq( v2 )
|
||||
self.x = self.x / v2.x
|
||||
self.y = self.y / v2.y
|
||||
end
|
||||
|
||||
return Vector2
|
||||
|
||||
@@ -208,4 +208,28 @@ function Vector3:equals( v2 )
|
||||
return RL.Vector3Equals( self, v2 )
|
||||
end
|
||||
|
||||
function Vector3:addEq( v2 )
|
||||
self.x = self.x + v2.x
|
||||
self.y = self.y + v2.y
|
||||
self.z = self.z + v2.z
|
||||
end
|
||||
|
||||
function Vector3:subEq( v2 )
|
||||
self.x = self.x - v2.x
|
||||
self.y = self.y - v2.y
|
||||
self.z = self.z - v2.z
|
||||
end
|
||||
|
||||
function Vector3:mulEq( v2 )
|
||||
self.x = self.x * v2.x
|
||||
self.y = self.y * v2.y
|
||||
self.z = self.z * v2.z
|
||||
end
|
||||
|
||||
function Vector3:divEq( v2 )
|
||||
self.x = self.x / v2.x
|
||||
self.y = self.y / v2.y
|
||||
self.z = self.z / v2.z
|
||||
end
|
||||
|
||||
return Vector3
|
||||
|
||||
@@ -145,6 +145,21 @@ int lcoreCompressData( lua_State* L );
|
||||
int lcoreDecompressData( lua_State* L );
|
||||
int lcoreEncodeDataBase64( lua_State* L );
|
||||
int lcoreDecodeDataBase64( lua_State* L );
|
||||
/* Automation events functionality. */
|
||||
int lcoreLoadAutomationEventList( lua_State* L );
|
||||
int lcoreUnloadAutomationEventList( lua_State* L );
|
||||
int lcoreExportAutomationEventList( lua_State* L );
|
||||
int lcoreSetAutomationEventList( lua_State* L );
|
||||
int lcoreSetAutomationEventBaseFrame( lua_State* L );
|
||||
int lcoreStartAutomationEventRecording( lua_State* L );
|
||||
int lcoreStopAutomationEventRecording( lua_State* L );
|
||||
int lcorePlayAutomationEvent( lua_State* L );
|
||||
int lcoreGetAutomationEventListCapacity( lua_State* L );
|
||||
int lcoreGetAutomationEventListCount( lua_State* L );
|
||||
int lcoreGetAutomationEvent( lua_State* L );
|
||||
int lcoreGetAutomationEventFrame( lua_State* L );
|
||||
int lcoreGetAutomationEventType( lua_State* L );
|
||||
int lcoreGetAutomationEventParams( lua_State* L );
|
||||
/* Input-related functions: keyboard. */
|
||||
int lcoreIsKeyPressed( lua_State* L );
|
||||
int lcoreIsKeyPressedRepeat( lua_State* L );
|
||||
|
||||
@@ -47,6 +47,7 @@ Ray uluaGetRay( lua_State* L, int index );
|
||||
NPatchInfo uluaGetNPatchInfo( lua_State* L, int index );
|
||||
BoneInfo uluaGetBoneInfo( lua_State* L, int index );
|
||||
Transform uluaGetTransform( lua_State* L, int index );
|
||||
// AutomationEvent uluaGetAutomationEvent( lua_State* L, int index );
|
||||
Buffer* uluaGetBuffer( lua_State* L, int index );
|
||||
Image* uluaGetImage( lua_State* L, int index );
|
||||
Texture* uluaGetTexture( lua_State* L, int index );
|
||||
@@ -65,6 +66,8 @@ Material* uluaGetMaterial( lua_State* L, int index );
|
||||
Model* uluaGetModel( lua_State* L, int index );
|
||||
ModelAnimation* uluaGetModelAnimation( lua_State* L, int index );
|
||||
rlRenderBatch* uluaGetRLRenderBatch( lua_State* L, int index );
|
||||
AutomationEvent* uluaGetAutomationEvent( lua_State* L, int index );
|
||||
AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index );
|
||||
/* Lua push types. */
|
||||
void uluaPushColor( lua_State* L, Color color );
|
||||
void uluaPushVector2( lua_State* L, Vector2 vector );
|
||||
@@ -78,6 +81,7 @@ void uluaPushRayCollision( lua_State* L, RayCollision rayCol );
|
||||
void uluaPushBoundingBox( lua_State* L, BoundingBox box );
|
||||
void uluaPushBoneInfo( lua_State* L, BoneInfo boneInfo );
|
||||
void uluaPushTransform( lua_State* L, Transform transform );
|
||||
// void uluaPushAutomationEvent( lua_State* L, AutomationEvent event );
|
||||
void uluaPushBuffer( lua_State* L, Buffer buffer );
|
||||
void uluaPushImage( lua_State* L, Image image );
|
||||
void uluaPushTexture( lua_State* L, Texture texture );
|
||||
@@ -96,5 +100,7 @@ void uluaPushMesh( lua_State* L, Mesh mesh );
|
||||
void uluaPushModel( lua_State* L, Model model );
|
||||
void uluaPushModelAnimation( lua_State* L, ModelAnimation modelAnimation );
|
||||
void uluaPushRLRenderBatch( lua_State* L, rlRenderBatch renderBatch );
|
||||
void uluaPushAutomationEvent( lua_State* L, AutomationEvent event );
|
||||
void uluaPushAutomationEventList( lua_State* L, AutomationEventList eventList );
|
||||
/* Utils. */
|
||||
int uluaGetTableLen( lua_State* L, int index );
|
||||
|
||||
229
src/core.c
229
src/core.c
@@ -1030,16 +1030,16 @@ int lcoreSetShaderValue( lua_State* L ) {
|
||||
|
||||
/* t = values index. */
|
||||
int t = 3, i = 0;
|
||||
lua_pushnil( L );
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
floats[i] = lua_tonumber( L, -1 );
|
||||
ints[i] = lua_tointeger( L, -1 );
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
lua_pop( L, 1 );
|
||||
/* Read values end. */
|
||||
|
||||
@@ -1949,6 +1949,223 @@ int lcoreDecodeDataBase64( lua_State* L ) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
## Core - Automation events functionality
|
||||
*/
|
||||
|
||||
/*
|
||||
> eventList = RL.LoadAutomationEventList( string|nil fileName )
|
||||
|
||||
Load automation events list from file, nil for empty list, capacity = MAX_AUTOMATION_EVENTS
|
||||
|
||||
- Success return AutomationEventList
|
||||
*/
|
||||
int lcoreLoadAutomationEventList( lua_State* L ) {
|
||||
if ( lua_isstring( L, 1 ) ) {
|
||||
uluaPushAutomationEventList( L, LoadAutomationEventList( lua_tostring( L, 1 ) ) );
|
||||
}
|
||||
else if ( lua_isnil( L, 1 ) ) {
|
||||
uluaPushAutomationEventList( L, LoadAutomationEventList( NULL ) );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.UnloadAutomationEventList( AutomationEventList list )
|
||||
|
||||
Unload automation events list from file
|
||||
*/
|
||||
int lcoreUnloadAutomationEventList( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
|
||||
UnloadAutomationEventList( list );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.ExportAutomationEventList( string fileName )
|
||||
|
||||
Export automation events list as text file
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lcoreExportAutomationEventList( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
const char* fileName = luaL_checkstring( L, 2 );
|
||||
|
||||
lua_pushboolean( L, ExportAutomationEventList( *list, fileName ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetAutomationEventList( AutomationEventList list )
|
||||
|
||||
Set automation event list to record to
|
||||
*/
|
||||
int lcoreSetAutomationEventList( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
|
||||
SetAutomationEventList( list );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetAutomationEventBaseFrame( int frame )
|
||||
|
||||
Set automation event internal base frame to start recording
|
||||
*/
|
||||
int lcoreSetAutomationEventBaseFrame( lua_State* L ) {
|
||||
int frame = luaL_checkinteger( L, 1 );
|
||||
|
||||
SetAutomationEventBaseFrame( frame );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.StartAutomationEventRecording()
|
||||
|
||||
Start recording automation events (AutomationEventList must be set)
|
||||
*/
|
||||
int lcoreStartAutomationEventRecording( lua_State* L ) {
|
||||
StartAutomationEventRecording();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.StopAutomationEventRecording()
|
||||
|
||||
Stop recording automation events
|
||||
*/
|
||||
int lcoreStopAutomationEventRecording( lua_State* L ) {
|
||||
|
||||
StopAutomationEventRecording();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.PlayAutomationEvent( AutomationEvent event )
|
||||
|
||||
Play a recorded automation event
|
||||
*/
|
||||
int lcorePlayAutomationEvent( lua_State* L ) {
|
||||
AutomationEvent* event = uluaGetAutomationEvent( L, 1 );
|
||||
|
||||
PlayAutomationEvent( *event );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> capacity = RL.GetAutomationEventListCapacity( AutomationEventList list )
|
||||
|
||||
Get automation event list capacity
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lcoreGetAutomationEventListCapacity( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
|
||||
lua_pushinteger( L, list->capacity );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> count = RL.GetAutomationEventListCount( AutomationEventList list )
|
||||
|
||||
Get automation event list count
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lcoreGetAutomationEventListCount( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
|
||||
lua_pushinteger( L, list->count );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> event = RL.GetAutomationEvent( AutomationEventList list, int index )
|
||||
|
||||
Get automation event from automation event list
|
||||
|
||||
- Failure return nil
|
||||
- Success return AutomationEvent
|
||||
*/
|
||||
int lcoreGetAutomationEvent( lua_State* L ) {
|
||||
AutomationEventList* list = uluaGetAutomationEventList( L, 1 );
|
||||
int index = luaL_checkinteger( L, 2 );
|
||||
|
||||
if ( 0 <= index && index < list->count ) {
|
||||
uluaPushAutomationEvent( L, list->events[ index ] );
|
||||
}
|
||||
else {
|
||||
TraceLog( LOG_WARNING, "GetAutomationEvent index %d out of bounds", index );
|
||||
lua_pushnil( L );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> frame = RL.GetAutomationEventFrame( AutomationEvent event )
|
||||
|
||||
Get automation event frame
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lcoreGetAutomationEventFrame( lua_State* L ) {
|
||||
AutomationEvent* event = uluaGetAutomationEvent( L, 1 );
|
||||
|
||||
lua_pushinteger( L, event->frame );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> type = RL.GetAutomationEventType( AutomationEvent event )
|
||||
|
||||
Get automation event type
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lcoreGetAutomationEventType( lua_State* L ) {
|
||||
AutomationEvent* event = uluaGetAutomationEvent( L, 1 );
|
||||
|
||||
lua_pushinteger( L, event->type );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> params = RL.GetAutomationEventParams( AutomationEvent event )
|
||||
|
||||
Get automation event params
|
||||
|
||||
- Success return int{}
|
||||
*/
|
||||
int lcoreGetAutomationEventParams( lua_State* L ) {
|
||||
AutomationEvent* event = uluaGetAutomationEvent( L, 1 );
|
||||
|
||||
lua_createtable( L, 4, 0 );
|
||||
|
||||
for ( int i = 0; i < 4; i++ ) {
|
||||
lua_pushnumber( L, event->params[i] );
|
||||
lua_rawseti( L, -2, i + 1 );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## Core - Input-related functions: keyboard
|
||||
*/
|
||||
|
||||
@@ -337,6 +337,34 @@ static void defineRLRenderBatch() {
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* AutomationEvent. */
|
||||
static void defineAutomationEvent() {
|
||||
lua_State* L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "AutomationEvent" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
}
|
||||
|
||||
/* AutomationEventList. */
|
||||
static int gcAutomationEventList( lua_State* L ) {
|
||||
if ( state->gcUnload ) {
|
||||
AutomationEventList* automationEventList = luaL_checkudata( L, 1, "AutomationEventList" );
|
||||
UnloadAutomationEventList( automationEventList );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void defineAutomationEventList() {
|
||||
lua_State* L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "AutomationEventList" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
lua_pushcfunction( L, gcAutomationEventList );
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* Assing globals. */
|
||||
|
||||
void assignGlobalInt( int value, const char* name ) {
|
||||
@@ -1033,6 +1061,8 @@ bool luaInit( int argn, const char** argc ) {
|
||||
defineModel();
|
||||
defineModelAnimation();
|
||||
defineRLRenderBatch();
|
||||
defineAutomationEvent();
|
||||
defineAutomationEventList();
|
||||
/* Define globals. */
|
||||
defineGlobals();
|
||||
platformDefineGlobals();
|
||||
@@ -1339,6 +1369,21 @@ void luaRegister() {
|
||||
assingGlobalFunction( "DecompressData", lcoreDecompressData );
|
||||
assingGlobalFunction( "EncodeDataBase64", lcoreEncodeDataBase64 );
|
||||
assingGlobalFunction( "DecodeDataBase64", lcoreDecodeDataBase64 );
|
||||
/* Automation events functionality. */
|
||||
assingGlobalFunction( "LoadAutomationEventList", lcoreLoadAutomationEventList );
|
||||
assingGlobalFunction( "UnloadAutomationEventList", lcoreUnloadAutomationEventList );
|
||||
assingGlobalFunction( "ExportAutomationEventList", lcoreExportAutomationEventList );
|
||||
assingGlobalFunction( "SetAutomationEventList", lcoreSetAutomationEventList );
|
||||
assingGlobalFunction( "SetAutomationEventBaseFrame", lcoreSetAutomationEventBaseFrame );
|
||||
assingGlobalFunction( "StartAutomationEventRecording", lcoreStartAutomationEventRecording );
|
||||
assingGlobalFunction( "StopAutomationEventRecording", lcoreStopAutomationEventRecording );
|
||||
assingGlobalFunction( "PlayAutomationEvent", lcorePlayAutomationEvent );
|
||||
assingGlobalFunction( "GetAutomationEventListCapacity", lcoreGetAutomationEventListCapacity );
|
||||
assingGlobalFunction( "GetAutomationEventListCount", lcoreGetAutomationEventListCount );
|
||||
assingGlobalFunction( "GetAutomationEvent", lcoreGetAutomationEvent );
|
||||
assingGlobalFunction( "GetAutomationEventFrame", lcoreGetAutomationEventFrame );
|
||||
assingGlobalFunction( "GetAutomationEventType", lcoreGetAutomationEventType );
|
||||
assingGlobalFunction( "GetAutomationEventParams", lcoreGetAutomationEventParams );
|
||||
/* Input-related functions: keyboard. */
|
||||
assingGlobalFunction( "IsKeyPressed", lcoreIsKeyPressed );
|
||||
assingGlobalFunction( "IsKeyPressedRepeat", lcoreIsKeyPressedRepeat );
|
||||
@@ -2619,7 +2664,7 @@ Ray uluaGetRay( lua_State* L, int index ) {
|
||||
Ray ray = { .position = { 0.0, 0.0, 0.0 }, .direction = { 0.0, 0.0, 0.0 } };
|
||||
|
||||
int t = index, i = 0;
|
||||
lua_pushnil( L );
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_istable( L, -1 ) ) {
|
||||
@@ -2646,7 +2691,7 @@ Ray uluaGetRay( lua_State* L, int index ) {
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
return ray;
|
||||
}
|
||||
|
||||
@@ -2915,6 +2960,20 @@ rlRenderBatch* uluaGetRLRenderBatch( lua_State* L, int index ) {
|
||||
return luaL_checkudata( L, index, "rlRenderBatch" );
|
||||
}
|
||||
|
||||
AutomationEvent* uluaGetAutomationEvent( lua_State* L, int index ) {
|
||||
if ( lua_islightuserdata( L, index ) ) {
|
||||
return (AutomationEvent*)lua_touserdata( L, index );
|
||||
}
|
||||
return luaL_checkudata( L, index, "AutomationEvent" );
|
||||
}
|
||||
|
||||
AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index ) {
|
||||
if ( lua_islightuserdata( L, index ) ) {
|
||||
return (AutomationEventList*)lua_touserdata( L, index );
|
||||
}
|
||||
return luaL_checkudata( L, index, "AutomationEventList" );
|
||||
}
|
||||
|
||||
/* Push types. */
|
||||
|
||||
void uluaPushColor( lua_State* L, Color color ) {
|
||||
@@ -3216,6 +3275,20 @@ void uluaPushRLRenderBatch( lua_State* L, rlRenderBatch renderBatch ) {
|
||||
luaL_setmetatable( L, "rlRenderBatch" );
|
||||
}
|
||||
|
||||
void uluaPushAutomationEvent( lua_State* L, AutomationEvent event ) {
|
||||
AutomationEvent* eventP = lua_newuserdata( L, sizeof( AutomationEvent ) );
|
||||
*eventP = event;
|
||||
luaL_setmetatable( L, "AutomationEvent" );
|
||||
}
|
||||
|
||||
void uluaPushAutomationEventList( lua_State* L, AutomationEventList eventList ) {
|
||||
AutomationEventList* eventListP = lua_newuserdata( L, sizeof( AutomationEventList ) );
|
||||
*eventListP = eventList;
|
||||
luaL_setmetatable( L, "AutomationEventList" );
|
||||
}
|
||||
|
||||
/* Utils. */
|
||||
|
||||
int uluaGetTableLen( lua_State* L, int index ) {
|
||||
luaL_checktype( L, index, LUA_TTABLE );
|
||||
int t = index, i = 0;
|
||||
|
||||
Reference in New Issue
Block a user