Skip to main content

Frame and Callback System

Aurora provides a robust callback system for timed execution of code. This system optimizes performance by managing update frequencies and staggering callbacks to prevent frame rate drops.

Callback Types

Aurora offers two main types of callbacks:

  1. Update Callbacks: Run at a fixed 0.1-second interval
  2. Tick Callbacks: Used for more precisely timed operations

Registration Methods

Aurora:OnUpdate(callback, enabled)

Registers a function to be called approximately every 0.1 seconds.

-- Parameters:
-- callback: function(elapsed) - Function to call with elapsed time parameter
-- enabled: boolean - Whether the callback starts enabled (default: true)
-- Returns: number - Unique ID for the callback

-- Example:
local updateId = Aurora:OnUpdate(function(elapsed)
-- Code to run every 0.1 seconds
print("Time elapsed: " .. elapsed)
end)

The framework automatically staggers update callbacks by assigning each one a small offset (0-0.09 seconds) to distribute processing load and prevent all callbacks from executing in the same frame.

Aurora:OnTick(callback, enabled)

Registers a function to be called on tick intervals (used for more precise timing operations).

-- Parameters:
-- callback: function(elapsed) - Function to call with elapsed time parameter
-- enabled: boolean - Whether the callback starts enabled (default: true)
-- Returns: number - Unique ID for the callback

-- Example:
local tickId = Aurora:OnTick(function(elapsed)
-- Code that needs precise timing
if player.casting then
-- Track casting progress
end
end)

Best Practices

Performance Optimization

  1. Use OnUpdate for Non-Critical Operations:

    • Interface updates
    • Status checks
    • Data collection
  2. Use OnTick for Time-Sensitive Operations:

    • Cast tracking
    • Interrupt timing
    • Precise rotation logic
  3. Enable/Disable as Needed:

    -- Store callback reference
    local myCallbackId

    -- Register with disabled state
    myCallbackId = Aurora:OnUpdate(function(elapsed)
    -- Heavy processing here
    end, false)

    -- Enable only when needed
    if inCombat then
    Aurora.updateCallbacks[myCallbackId].enabled = true
    else
    Aurora.updateCallbacks[myCallbackId].enabled = false
    end

Memory Management

Always remove callbacks that are no longer needed:

-- When a module is disabled or no longer needs the callback
Aurora:RemoveCallback(callbackId, true)

Notes

warning

Avoid excessive processing in update callbacks. Keep operations light and efficient to prevent frame rate drops.