sm.event

Events for communicating between scripts by running callbacks.

Constants

Name Type Description
types table The event types list.

types

Value type: table

Event types

{
    validate, -- Will make sure script instance exists, and that the callback is declared on the receiving end, before queuing the event. This is the default type.
    blind,    -- Will blindly queue the event without making any validation checks. Can be useful for sending events to script we know will come alive the next tick.
    instant,  -- Same as blind event, but sent immediately.
}

Functions

sendToCharacter

sm.event.sendToCharacter( character, callback, args, eventType, pauseSave )

Sends an event to a specified Character.

Parameters:

Name Type Description
character Character The character.
callback string The function name in a character script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToGame

sm.event.sendToGame( callback, args, eventType, pauseSave )

Sends an event to the game script.

Parameters:

Name Type Description
callback string The function name in the game script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToHarvestable

sm.event.sendToHarvestable(
    harvestable,
    callback,
    args,
    eventType,
    pauseSave
)

Sends an event to a specified Harvestable.

Parameters:

Name Type Description
harvestable Harvestable The harvestable.
callback string The function name in a harvestable script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToInteractable

sm.event.sendToInteractable(
    interactable,
    callback,
    args,
    eventType,
    pauseSave
)

Sends an event to a specified Interactable.

Parameters:

Name Type Description
interactable Interactable The interactable.
callback string The function name in an interactable script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToPlayer

sm.event.sendToPlayer( player, callback, args, eventType, pauseSave )

Sends an event to a specified Player.

Parameters:

Name Type Description
player Player The player.
callback string The function name in a player script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToScriptableObject

sm.event.sendToScriptableObject(
    scriptableObject,
    callback,
    args,
    eventType,
    pauseSave
)

Sends an event to a specified ScriptableObject.

Parameters:

Name Type Description
scriptableObject ScriptableObject The scriptableObject.
callback string The function name in a scriptableObject script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToTool

sm.event.sendToTool( tool, callback, args, eventType, pauseSave )

Sends an event to a specified Tool.

Parameters:

Name Type Description
tool Tool The tool.
callback string The function name in a tool script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully queued.

sendToUnit

sm.event.sendToUnit( unit, callback, args, eventType, pauseSave )

Sends an event to a specified Unit.

Parameters:

Name Type Description
unit Unit The unit.
callback string The function name in a unit script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.

sendToWorld

sm.event.sendToWorld( world, callback, args, eventType, pauseSave )

Sends an event to a specified World.

Parameters:

Name Type Description
world World The world.
callback string The function name in a world script.
args (optional) any Optional arguments to be sent to the callback.
eventType (optional) integer The type of event. Defaults to sm.event.types.validate.
pauseSave (optional) boolean Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only).

Returns:

Name Type Description
result boolean Returns true if the event was successfully processed.