backIndex

Xelagot action script

Motion: Warp, WarpLocal, MoveTo, Pitch, Step, To, Walk, Wait, Stop,
LookAt, Avoid, StopNoticing

All location variables like @a can be substituted by person &a or object ~a variables

Warp @a Teleports the bot to the given position (including Yaw but excluding 3.4 Pitch) and world. See next section for when the bot is not in a universe or world.
WarpLocal @a Teleports the bot to the given position (including Yaw but excluding 3.4 Pitch), ignoring the world name (stays in the same world).
MoveTo @a (3.434) Teleports the bot to the given position (including Yaw but excluding 3.4 Pitch), ignoring the world name (stays in the same world). Does not stop Walk, Follow, Join, Blimp action!
3.4
Pitch @a
Pitch %a
Sets the pitch of the bot either to the Pitch of Location variable @a or to angle %a (in degrees). Note that the avatar Pitch (look down/up) in ActiveWorlds is restricted to +/- 90 degrees, so this statement follows the AW restriction automatically. The code will reduce the given angle to a +/- 180 interval by adding or subtracting 360 degrees as necessary, and then apply the restriction. After reduction to the +/- 180 degrees interval, a positive angle is 'look down', a negative angle is 'look up'.

For the pitch to be seen by browsers, the bot must be flying. To do this, use
AvatarState Flying
See Person variables and operations. Bots

Note: the +/- 90 degrees angle restriction applies to browser users. As from xelagot 3.601 I removed this restriction from the bot's Pitch statement: the full +/- 180 degrees is now available.
Step %a sets the step in metres per second to be used by motion statements according to the value of %a, which can be a numeric variable or a literal number.
To @a Do not use in event handlers. Starts the bot moving gradually towards position @a, according to the value of the step statement. Blocks the execution of the script until the bot reaches destination. History: this is one of the oldest script statements :)
To @a : tag Do not use in event handlers. Starts the bot moving gradually towards position @a, according to the value of the step statement. Blocks the execution of the script until the bot reaches destination. The optional tag, preceded by a colon, is there as a comment, it should not be confused with the assignement statement for location: there the colon separates the actual location from an optional world name
Walk @a
Walk @a : tag
Used in the main part of the script: if the bot is still executing a Walk statement, the script processor waits until that Walk is done before proceeding with this Walk.
Used in event handlers: proceedes inmediately, interrupting any ongoing Walk.

Starts the bot moving gradually towards position @a, according to the value of the step statement. Does not block the execution of the script statements following it, as a To statement would. When the bot reaches destination, it triggers the event WalkComplete.
The optional tag, preceded by a colon, is there as a comment, it should not be confused with the assignement statement for location: there the colon separates the actual location from an optional world name. Here, it serves not only as a comment, it is also passed back to the WalkComplete event handler and can be retrieved there with GetMessage $a. It is a peculiar tag: it can be a string variable if it is one word starting with $, but it can also be an unquoted string. See examples further down.
PauseWalk if the bot is executing a Walk statement, pauses the walk. As is the case with the walk statement, the execution of the script is not blocked. May be followed by a Wait statement if one needs to block the execution of the script as well.
ResumeWalk if the bot was executing a Walk statement and is paused, resumes the walk.
Wait %a the bot waits %a seconds before executing the next script statement: blocks the execution of the script for %a seconds. Notice that it will not block event handlers, nor actions which are executed independently by the bot, such as random movement, blimp, walk, or join. Decimals are allowed:
Wait 3.5
Stop Stops any ongoing follow/join, random, blimp and walk movement.

As from version 3.304, xelagots can sense terrain if terrain is available. Terrain sensing is OFF by default for To and Walk motion. The following statements apply:

ToTerSensing ON
ToTerSensing OFF
Enables or disables terrain sensing when executing To motion. Default: OFF
ToTerMinAlt %a Sets the minimum altitude the bot must follow above the terrain (in metres), i.e. it may not go lower than this value relative to the terrain. The default is 0. If both maximum and minimum are 0, the bot will follow the terrain practically touching it. Notice that on slopes, the bot will be slightly above the terrain (as in the browser) if both values are 0 so as to keep the feet above the ground. For bird-bots, you may want to set this value to maybe 2 or 3 metres, so that the bird does not touch the terrain.
ToTerMaxAlt %a Sets the maximum altitude the bot must follow above the terrain (in metres). The default is 0. If the maximum altitude is lower than the minimum altitude, it is disregarded and the bot is not limited by a maximum altitude above the terrain (no maximum limit).
WalkTerSensing ON
WalkTerSensing OFF
Enables or disables terrain sensing when executing Walk motion. Default: OFF
WalkTerMinAlt %a Sets the minimum altitude the bot must follow above the terrain (in metres), i.e. it may not go lower than this value relative to the terrain. The default is 0. If both maximum and minimum are 0, the bot will follow the terrain practically touching it. Notice that on slopes, the bot will be slightly above the terrain (as in the browser) if both values are 0 so as to keep the feet above the ground. For bird-bots, you may want to set this value to maybe 2 or 3 metres, so that the bird does not touch the terrain.
WalkTerMaxAlt %a Sets the maximum altitude the bot must follow above the terrain (in metres). The default is 0. If the maximum altitude is lower than the minimum altitude, it is disregarded and the bot is not limited by a maximum altitude above the terrain (no maximum limit).
LookAt &p (3.434) Turns the bot towards person &p until StopNoticing is called.
Avoid &p (3.434) Turns the bot away from person &p until StopNoticing is called.
StopNoticing (3.434) Cancels LookAt and Avoid.


Examples of To statements

Step 0.70
To 2.781n 0.063e 0.01a 0.0°
To 2.757n 0.286e 0.01a 0.0° :Girl
Wait 15
To 2.841n 0.265e 0.01a 0.0°

Using variables, the same script part might look like this:

var %step = 0.7, @a1, @a2, @a3, %standard_interval
@a1 = 2.781n 0.063e 0.01a 0.0
@a2 = 2.757n 0.286e 0.01a 0.0
@a3 = 2.841n 0.265e 0.01a 0.0
%standard_interval = 15

Step %Step
To @a1
To @a2 :Girl
Wait %standard_interval
To @a3


Examples of Walk statements

# Section 1
OnChatEvent Chat
OnWalkCompleteEvent EndWalk1
%i = 1
@p = 73s 25e 100.5a
Step 1.2
Walk @p : Got to the Moon!
# more code ...
# can be almost anything:
# say, text, gestures... 
Say I started moving towards the Moon...
# this next Wait does not stop the bot from walking
# it only delays the Say statement
Wait 5
Say ... and hope to get there soon :)
# ...
# here one must loop,
# awaiting the WalkComplete event in EndWalk1.
Label MoonLoop
   IfInt %i <> 0 Goto MoonLoop
#....

# Section 2
OnWalkCompleteEvent EndWalk2
$b = "Got somewhere :)"
Step 0.7
Walk 25.3n 73w 5a : $b
# more code here if needed
# ...
# At the next Walk statement
# the script stops executing
# until this Walk has ended :
# a loop is not needed between two Walk statements.
# Notice that the variables @p, $b and %i
# required by the next Walk section
# are set in the EndWalk2 event handler...
Walk @p : $b
# more code ...
# can be almost anything:
# say, text, gestures... 
Say I started moving towards the Moon...
# ...
# here one must loop,
# awaiting the WalkComplete event in EndWalk3.
Label MoonLoop2
   IfInt %i <> 0 Goto MoonLoop2
#....



# event handlers
Event Chat
   GetChatline $a
   IfString $a = "freeze!" PauseWalk
   Else IfString $a = "go!" ResumeWalk
EndEvent

Event EndWalk1
   GetMessage $a
   IfString $a <> "" Say $a
   %i = 0
EndEvent

Event EndWalk2
   GetMessage $a
   IfString $a <> "" Say $a
   # set partameters for next walk statement
   @p = 73s 25e 100.5a
   $b = "Got to the Moon!"
   Step 1.4
   %i = 1
   OnWalkCompleteEvent EndWalk3
EndEvent

Event EndWalk3
   GetMessage $a
   IfString $a <> "" Say $a
   %i = 0
EndEvent


backIndex