-
Notifications
You must be signed in to change notification settings - Fork 2
ObstacleScript Globals
Jasdac edited this page Mar 10, 2021
·
10 revisions
This is a list of built in constants, definitions, macros, and globals.
These can be used anywhere in a project.
Definition | Value | Description |
---|---|---|
PUB_CHAN | 0xB00B | This is the channel ObstacleScript communicates on in default communication. |
OBSTACLE_CHAN | 0xC34 | This is the base channel for obstacle custom communication. Each obstacle usually has its own channel which is an offset from this in order to speed up communication. |
PLAYERS | list player_keys | Requires #define USE_PLAYERS , contains an auto updated list of player keys in the current game |
end | Synonym for } |
These can be used inside the main event handler.
Definition | Value | Description |
---|---|---|
METHOD_ARGS | list arguments | A list containing all the arguments passed to an event/method |
SENDER_SCRIPT | str script | The sender script that sent a method. If it was an event, this will always be "!" |
EVENT_TYPE/METHOD_TYPE | int type | The ID of the event or method that was called |
SENDER_KEY | key id | The key of an object that sent a method, or "" if it was sent from within the linkset |
NOT_METHOD | bool is_not_method | Checks if the call was not a method |
IS_METHOD | bool is_method | Checks if the call was a method |
Definition | Description |
---|---|
raiseEvent( int evt, spread data ) | Raises an event |
runMethod( key/int target, str script, int method, spread data ) | Runs a method on a Module. Target can be either a key if you want to run it on a different object, or a link number. You can use LINK_ALL etc. Script is the name of the Module to send to. Method is the method id (see the Module's header script, and data are the arguments to send. |
runOmniMethod( str script, int method, spread data ) | Same as above but sent as a regionsay. Use sparingly since it can lead to a lot of parsing. |
forPlayer( index, player ) | Quick way of iterating over players. Ex forPlayer( index, player ) llOwnerSay("Player #"+(string)index+": "+llKey2Name(player)); end . Note that index creates a new iterator, so you can't use the same name for your iterator in the same scope. If you want to iterate over the players multiple times in a row, use something like index_1, index_2... |
Definition | Description |
---|---|
handleMethod( method ) | Handles a specific method called on your Module. Usage handleMethod( <methodID> ) ...code... end
|
handleInternalMethod( method ) | Same as above, but only allows if the method caller script was in the same linkset |
handleOwnerMethod( method ) | Same as above, but only allows if the method caller script has the same owner |
handleEvent( script, evt ) | Handles a specific event from a script. Usually wrapped in the header file of a script such as onAttachmentAttached( id )
|
argStr( index ) | Gets an argument from the event or method by index, and returns a string. Ex string firstArg = argStr(0) gets the first argument as a string. |
argInt( index ) | Same as above but returns an integer |
argKey( index ) | Same as above but returns a key |
argFloat( index ) | Same as above but returns a float |
argRot( index ) | Same as above but returns a rotation |
argVec( index ) | Same as above but returns a vector |
onMethod( method ) | Event capture for ALL method calls. Not recommended, use the header file macros instead. |
isMethodInternal() | Checks if the method was requested by a script within the linkset. Not recommended, use handleInternalMethod() instead |
isMethodInternalInline() | Checks if the method was requested by a script within the linkset, but can be used within an if statement. Ex: if( isMethodInternalInline() ) Not recommended, use handleInternalMethod() instead |
isMethodByOwner() | Similar to above, but allows external linksets if they have the same owner |
isMethodByOwnerInline() | Similar to above, but allows external linksets if they have the same owner |
isEventByOwner() | Synonym for isMethodByOwner |
isEventByOwnerInline() | Synonym for isMethodByOwnerInline |
isEventNotByOwner() | Opposite of isMethodByOwner |
These are definitions you can add to the top of your script to enable extra functionality. See Module Dissection for info on how to set these up.
Custom handlers:
|
Default internal events. These are just wrappers around the default SL events.
Definition | Handler |
---|---|
USE_CONTROL | onControl( level, edge ) |
USE_STATE_ENTRY | onStateEntry() |
USE_SENSOR | onSensor( total ) |
USE_NO_SENSOR | onNoSensor() |
USE_OBJECT_REZ | onObjectRez( id ) |
USE_CHANGED | onChanged( change ) |
USE_RUN_TIME_PERMISSIONS | onRunTimePermissions( perm ) |
USE_ATTACH | onAttach( id ) |
USE_ON_REZ | onRez( nr ) |
USE_COLLISION_START | onCollisionStart( total ) |
USE_COLLISION_END | onCollisionEnd( total ) |
USE_TOUCH | onTouch( total ) |
USE_TOUCH_START | onTouchStart( total ) |
USE_TOUCH_END | onTouchEnd( total ) |
These are events tied to the USE definitions above.
Event | Arguments | Requires | Description |
---|---|---|---|
onPlayersUpdated | USE_PLAYERS | Raised when the PLAYERS global has been updated with new players. |