Skip to main content

RunLocalEvent

This function was added in DSL 4

Description

Activate an event of type, passing any arguments you want.

tip

Keep in mind that tables in Lua are passed by reference, so a decent strategy for allowing other scripts to respond to your event is by passing some sort of table.

The result is false unless at least one of the callbacks return true. This can be used as a way of letting certain events be cancelled, or for any other arbitrary use.

function RunLocalEvent(type, ...) --[[ ... ]] end

Parameters

  • type: string - The type of the event to run. This is usually a string that identifies the event.
  • ...: any - Any number of arguments to pass to the event. These can be any Lua values, including tables, numbers, strings, etc.

Return Values

  • result: boolean - Returns true if at least one of the callbacks for the event returned true, otherwise returns false.

Example

RegisterLocalEventHandler('MyMod:MyEvent', function(arg1, arg2)
print('MyMod:MyEvent was triggered with arguments:', arg1, arg2)
return true -- Indicate that the event was handled
end)
RunLocalEvent('MyMod:MyEvent', 'Hello', 42)

See Also