-
Notifications
You must be signed in to change notification settings - Fork 2
ObstacleScript Globals
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. |
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. |
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.
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 ) |
This definition allows you to automatically get a PLAYER list added as a global, which is auto updated with a list of players in the game.
Definition | Type | Description |
---|---|---|
list PLAYERS | global | Contains an auto updated list of player keys in the current game |
onPlayersUpdated() | event | Raised when the PLAYERS global has been changed |
forPlayer( index, player ) | Loop | 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... |
This definition allows you to use the built in multi timer system.
Definition | Type | Description |
---|---|---|
handleTimer( id ) | Event | Handles a specific timer by id, ex handleTimer("myTimer") ...code... end
|
onTimer( id ) | Event | Handles all timers, you'll have to filter by the id variable manually ex onTimer( id ) llOwnerSay("Timer "+id+" triggered"); end
|
setTimeout( string id, float time ) | function | Sets a timer to run once, capture the timer with the handleTimer or onTimer event listeners. id is a string and time is in seconds. Starting a timer with the same id as another removes the first one. |
setTimer( string id, float time ) | function | Synonym of above. |
setInterval( string id, float time ) | function | Sets a timer to repeat until you manually turn it off. Capture the timer with handleTimer or onTimer. Keep in mind that interval and timeout share the same IDs. |
unsetTimer( string id ) | function | Removes a timeout or interval |
unsetTimersThatStartWith( string id ) | function | Removes all timers that start with id |
The listen handler is separate to the built in LSL events since it also needs to handle methods.
Definition | Type | Description |
---|---|---|
onListen( channel, message ) | event | Handles all listeners. If you're looking for the key of the object that sent the listen, use the event global SENDER_KEY |
addListen(channel) | function | Sets up a listener for everyone on channel. You can also use the LSL built in llListen() function instead of this |
handleListenTunnel() | event template | You shouldn't need to use this. This is used only by the root scripts in a linkset. In the HUD this is handled by Com, in an Asset it's handled in Portal, and in a level it's handled by Level. |
setupListenTunnel() | function | Same as above, you shouldn't need to use this. Used in root scripts onStateEntry to setup the main ObstacleScript communications |
handleDebug() | event template | As above, used in root scripts to handle the Debug Console |
setupDebug( chan ) | function | Used in root scripts to setup the debug console |
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. |
The ObstacleScript comes with a bunch of built in macros and shortcuts:
Entry | Type | Example | Description |
---|---|---|---|
elseif | synonym | if(a){}elseif(b){} |
Synonym for else if |
elif | synonym | if(a){}elif(b){} |
Synonym for else if |
true | synonym | if(true) |
Lowercase version of TRUE |
false | synonym | if(false) |
Lowercase version of FALSE |
rotateDoor( float)deg ) | macro | rotateDoor(90) |
Rotates an object around the global Z axis |
int | synonym | int nr = 69; |
Synonym for integer |
str | synonym | str text = "Hi"; |
Synonym for string |
bool | synonym | bool val = TRUE; |
Synonym for integer |
int count( (list)input ) | synonym | count([1,2,3]) -> 3 |
Synonym for llGetListLength |
Infinity | synonym | float inf = Infinity; |
Highest possible float value |
NaN | synonym | float nan = NaN; |
Not sure why you'd want to use this, but NaN is actually a value in LSL |
ONE_VECTOR | synonym | vector white = ONE_VECTOR; |
Synonym for <1,1,1> |
MAXINT | synonym | integer max = MAXINT; |
Highest value 32 bit signed integer |
int floor( (float)input ) | synonym | integer n = floor(0.8); -> 0 |
Synonym for llFloor() |
list split( string input, var separator ) | synonym | list spl = split("A$B$C", "$"); -> ["A","B","C"] |
Synonym for llParseStringKeepNulls(input, (list)(separator), []) |
string join( list input, var separator ) | synonym | string data = join(["A","B","C"], ":"); -> "A:B:C" |
Synonym for llDumpList2String(input, (str)(separator)) |
int uuidChan( key id ) | macro | integer chan = uuidChan(llGetOwner()) |
Creates an integer from a UUID based on the first 8 bytes |
string mkarr( spread input ) | synonym | string jsonArray = mkarr("A" + "B" + "C"); -> "[\"A\",\"B\",\"C\"]" |
Creates a JSON array string |
string trim( var input ) | synonym | string data = trim(" ABC "); -> "ABC" |
Synonym for llStringTrim with auto typecast to string |
AND | synonym | if( 1 AND 2 ) |
Synonym for && |
OR | synonym | if( 1 OR 2 ) |
Synonym for |
IS | synonym | if( a IS 1 ) |
Synonym for == |
stopAllObjectAnimations() | macro | stopAllObjectAnimations() |
Stops all animesh animations in the object |
qd( spread message ) | macro | qd( "The value of" + a + "is" + 3) -> [12.832 Controls.lsl @ 114] The value of :: 13 :: is :: 3 |
Basically an ownersay that uses a spread as well as outputting the current seconds and milliseconds on the clock, what script said it, and what line. |
string randElem( spread input ) | macro | string nr = randElem( 1 + 2 + 3 ) -> 3 |
Picks a random element from a list or spread and returns it as a string. |
memLim( float multi ) | macro | memLim( 1.5 ) |
Sets the script memory limit to a multiplier of llGetUsedMemory() |
string l2s( list input ) | synonym | string s = l2s(["a","b"], 0); -> "a" |
Synonym for llList2String |
integer l2i( list input ) | synonym | integer s = l2i([0,1], 0); -> 0 |
Synonym for llList2Integer |
key l2k( list input ) | synonym | key s = l2k(["a...","b..."], 0); -> "a..." |
Synonym for llList2Key |
vector l2v( list input ) | synonym | vector s = l2v([ZERO_VECTOR,ONE_VECTOR], 0); -> ZERO_VECTOR |
Synonym for llList2Vector |
rotation l2r( list input ) | synonym | rotation s = l2r([ZERO_ROTATION, <0,0,1,0>], 0); -> ZERO_ROTATION |
Synonym for llList2Rotation |
float l2f( list input ) | synonym | float s = l2f([0.0, 0.1], 0); -> 0.0 |
Synonym for llList2Float |
vector l2vs( list input ) | synonym | vector s = l2v(["<0,0,1>","<1,0,0>"], 0); -> <0,0,1> |
Same as l2v except it explicitly typecasts. Ex l2v(["<1,1,1>"], 0) would output <0,0,0> because the element is a string, whereas l2vs would output <1,1,1> |
rotation l2rs( list input ) | synonym | float s = l2rs(["<0,0,1,0>"], 0); -> <0,0,1,0> |
Same as above except for rotation |
bool isset(var value) | macro |
isset(JSON_INVALID) -> false |
Checks if a string is not "" or JSON_INVALID, since if(JSON_INVALID) evaluates to TRUE |
rotation norm2rot( vector normal, vector axis ) | macro | norm2rot(<0,0,1>, <1,0,0>) -> <0.707107, 0.000000, 0.707107, 0.000000> |
Turns a normal into a rotation |
RC_DEFAULT | synonym | llCastRay(a, b, RC_DEFAULT) |
Synonym for [RC_DEJECT_TYPES, (RC_REJECT_AGENTS |
vector int2vec( int input ) | macro | int2vec(input) |
Decompresses an integer consisting of 8bitsX 8bitsY 7bitsZ into a vector |
vector vecFloor( vector input ) | macro | vecFloor(<0.3, 1.8, 3.5>) -> <0,1,3> |
Same as llFloor except for vectors |
int vec2int( vector input ) | macro | vec2int(<15, 38, 1000>) |
Lets you store values where X, Y are integers between 0 and 255, and Z is between 0 and 8191 as a single integer. Can be passed to the LSL rez functions to quickly position an object in the on_rez event |
vector reflect( dir, norm ) | macro | reflect(<1,0,0>, normal) |
Can be used in raycasting to create reflections |
xLookAt( vector pos ) | macro | xLookAt(prPos(llGetOwner())) |
Similar to llLookAt except it points X towards the target |
xLookAtLinked( vector pos ) | macro | xLookAtLinked(prPos(llGetOwner())) |
Tries to point a sub-prim's X towards a location |
idOwnerCheck | macro | listen( integer channel, string name, key id, string message){ idOwnerCheck } |
Synonym for if( llGetOwnerKey(id) != llGetOwner() )return; |
vector prPos( key prim ) | macro | vector ownerPos = prPos(llGetOwner()) |
Gets the position of a prim |
rotation prRot( key prim ) | macro | rotation ownerRot = prRot(llGetOwner()) |
Gets the rotation of a prim |
string prDesc( key prim ) | macro | string desc = prDesc(prim) |
Gets the description of a prim |
int prLinkedToMe( key prim ) | macro | int isLinked = prLinkedToMe(prim) |
Gets whether a prim is in the same linkset |
key prRoot( key prim ) | macro | key rootPrim = prRoot(prim) |
Gets the root key of a prim |
int prAttachPoint( key prim ) | macro | int attached = prAttachPoint(prim) > 0 |
Gets the attach point of a prim |
key prSpawner( key prim ) | macro | key spawner = prSpawner(prim) |
Gets the UUID of the object or avatar that rezzed a prim |
int prPhantom( key prim ) | macro | int isPhantom = prPhantom(prim) |
Gets whether a prim is phantom |
key mySpawner() | macro | key spawner = mySpawner() |
Gets the UUID of the object or avatar that rezzed the prim the script is in |
float prAngX( key target, varName ) | macro | prAngX(prim, angle) -> float angle = -0.3; |
Creates a new float named the same as you put in varName, and assigns the angle offset from the calling object's positive X to that float. For an instance, if the scripted object has a ZERO rotation and the object we compare to is on the object's left. The angle will be PI/2. |
float myAngX( key target, varName ) | macro | myAngX(prim, angle) -> float angle = -0.3; |
Inverse of above, checking the object's angular offset compared to the target. |
string j( str json, spread index ) | macro | string val = j("{\"a":[1,2,3]}", "a", 1) -> "2" |
Fetches a value from a JSON string |
string allRound( var input ) | function | string r = allRound(<1.3,1.8,0>); -> "<1,2,0>" |
Rounds a float, vector, or rotation, and returns a string. |
list _kfmConv( list input ) | function | list conv = _kfmConv(["<0,0,0,1>","<1,2,3>"]); -> [<0,0,0,1>, <1,2,3>] |
Automatically typecasts lists and vectors from a JSON array into lists and vectors. Useful for things like keyframed motions. Rotations are also automatically normalized. |
warpPlayerToSurface( player, pos, rot, allowUnsit ) | function | warpPlayerToSurface(llGetOwner(), <10,5,5>, ZERO_ROTATION, TRUE) |
Handy shortcut for teleporting a player to a surface using the RLV module. Does a raycast at the target position to get the surface, and then warps the player onto that surface. |