sm.event
Events for communicating between scripts by running callbacks.
Constants:
Functions:
sendToCharacter sendToGame sendToHarvestable sendToInteractable sendToPlayer sendToScriptableObject sendToTool sendToUnit sendToWorld
sm.event.types 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. |
sm.event.sendToCharacter(character, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Character.
Parameters:
| Type | Name | Description |
| Character | character | The character. |
| string | callback | The function name in a character script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToGame(callback, args?, eventType?, pauseSave?)
Sends an event to the game script.
Parameters:
| Type | Name | Description |
| string | callback | The function name in the game script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToHarvestable(harvestable, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Harvestable.
Parameters:
| Type | Name | Description |
| Harvestable | harvestable | The harvestable. |
| string | callback | The function name in a harvestable script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToInteractable(interactable, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Interactable.
Parameters:
| Type | Name | Description |
| Interactable | interactable | The interactable. |
| string | callback | The function name in an interactable script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToPlayer(player, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Player.
Parameters:
| Type | Name | Description |
| Player | player | The player. |
| string | callback | The function name in a player script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToScriptableObject(scriptableObject, callback, args?, eventType?, pauseSave?)
Sends an event to a specified ScriptableObject.
Parameters:
| Type | Name | Description |
| ScriptableObject | scriptableObject | The scriptableObject. |
| string | callback | The function name in a scriptableObject script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToTool(tool, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Tool.
Parameters:
| Type | Name | Description |
| Tool | tool | The tool. |
| string | callback | The function name in a tool script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully queued. |
sm.event.sendToUnit(unit, callback, args?, eventType?, pauseSave?)
Sends an event to a specified Unit.
Parameters:
| Type | Name | Description |
| Unit | unit | The unit. |
| string | callback | The function name in a unit script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |
sm.event.sendToWorld(world, callback, args?, eventType?, pauseSave?)
Sends an event to a specified World.
Parameters:
| Type | Name | Description |
| World | world | The world. |
| string | callback | The function name in a world script. |
| any | args? | Optional arguments to be sent to the callback. |
| integer | eventType? | The type of event. Defaults to sm.event.types.validate. |
| boolean | pauseSave? | Optional, defaults to true. If true, pauses saving for 1 tick for delayed event types (server only). |
Returns:
| Type | Description |
| boolean | result Returns true if the event was successfully processed. |