backIndex

Xelagot action script

World attributes and rights. Global Mode


EVENT WORLDATTRIBUTES
Introduced in the Action Script in February 2001, refer to Events: WorldAttributes.
5 WORLD/UNIVERSE ATTRIBUTES
These attributes can be queried at all times the bot is in a world. If the answer is not available, they return -1. They are needed to know if certain statements will work.

Some usefull build numbers:
2.1 world server build 19
2.2 world server build 21
3.0 world server build 23
3.1 universe server build 28
3.1 world server build 28


LIST OF WORLD ATTRIBUTES
World attributes can be dumped to a string list by all bots (it only needs to be caretaker if it wants the object path, other attributes are for all bots) in any world at any moment, not only when the bot receives the WorldAttributes event:
GENERAL SETTINGS AND RIGHTS, LIST BATCH STATEMENT
A string list containing world attributes as a name/value pair can be used by Caretaker bots to change the world attributes in one statement: Only the attributes mentioned in the list will be changed, if they contain valid data. Excluded are the object password, and any read-only attributes. See your world file in the bot's World folder (universe subfolder): that file contains the latest retrieved attributes and is being constantly updated. This action triggers the Event WorldAtrributes.

NB: do not open the file while the attributes are being changed or the bot is logging in. You can copy it safely to another location to examine it at other moments.

You can edit a copy of your world file, remove any unwanted attributes (for example, the ones related to rights: entry, bots, etc). You can then load that file to a string list and apply the changes at any time.

See example 5


GENERAL SETTINGS AND RIGHTS, SEPARATE STATEMENTS
The bot can change all world attributes except for the object password. These changes can only take place if the bot has Caretaker privileges for the world indicated in the script by the SetWorld statement, and is actually present there. The section of the script attempting to modify the world attributes must begin and end with the following statements: NB: All strings are limited to 255 characters.

This action triggers the Event WorldAtrributes.

The following statement only (comments allowed) may be used after SetWorld and before ChangeAttributes. Attributes marked (AW 3.0) apply to the Active Worlds SDK 3.0, world server build 23 or higher, and only affect new 3.0 browsers.

See examples 1, 2, 3 and 4 below.

The checkboxes: The rights: Lights and Fog (AW 3.0): Sky: (3.4, replaces sky colour function of BackdropColor) Clouds: (3.4) Water: (3.4) World light (sun) texture: (3.4) Terrain surface and gravity: (3.4) Sounds: (3.4)
INDIVIDUAL ENTRIES IN WORLD RIGHTS
Individual entries in the world rights categories can be changed, using two sets of statements: one for adding, one for removing. One can add or remove the * symbol, or any citizen number, including the 0 for tourists. These statements are conditional: they have the
If... var statement1
Else statement2
form. The notation var is peculiar to this series of statements. It can be one of the following: This is the list of statements:

For example, these are legal statements:
IfGiveBuild %b Gosub NewBuilder
IfTakePublicSpeaker &p SayConcat &p ", sorry, you are no longer PS"
IfTakeEnter -1 Say "The world is closed"

When using the string variable variant, the rest string can be used for looping until it is totally processed (check to see if it is empty to exit the loop). Please note the following:

The If statement will fail and execute the alternative Else (if present) in the following cases:


GLOBAL MODE

World servers 3.3 (build 39 upwards) introduce a new mode for Caretaker bots: Global Mode. In this mode, which must be selected before entering a world (or the bot must leave and re-enter), the bot perceives much more than before: all avatars present in the world, for example. New Action Script statements support this:


EXAMPLES

Example 1

Here is an example of a script I used to test changing the backdrop. This script loops, changing the backdrop from 'moonlight.jpg' to 'purplefire.jpg' and back, once every 60 seconds. It also modifies the backdrop colour.

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
label start

SetWorld xelagon
Backdrop moonlight
BackdropColor 43 2 34
ChangeAttributes
wait 60

SetWorld xelagon
Backdrop purplefire
BackdropColor 128 0 24
ChangeAttributes
Wait 60

goto start
end
   


Example 2

A more ellegant way of writing this would be:

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
label start
gosub moonlight
wait 60
gosub purplefire
Wait 60
goto start
end
Sub moonlight
   SetWorld xelagon
   Backdrop moonlight
   BackdropColor 43 2 34
   ChangeAttributes
Return
Sub purplefire
   SetWorld xelagon
   Backdrop purplefire
   BackdropColor 128 0 24
   ChangeAttributes
Return


Example 3

Another more complex example:

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
var $sub, $world, $backdrop, %red, %green, %blue, %wait
$world = xelagon
%wait = 300
%i=0
label start
   IfInt %i > 3 %i=0
   IfInt %i = 3 $sub = moon
   Else IfInt %i = 2 $sub = sun
   Else IfInt %i = 1 $sub = snow
   Else $sub = rain
   gosub $sub
   gosub ChangeBackdrop
   wait %wait
   inc %i
goto start
End

Sub moon
   $backdrop = "moonlight"
   %red = 64 
   %green = 64
   %blue = 64
Return

Sub sun
   $backdrop = "sunny"
   %red = 200 
   %green = 200
   %blue = 128
Return

Sub snow
   $backdrop = "snowscape"
   %red = 255 
   %green = 255
   %blue = 255
Return

Sub rain
   $backdrop = "thenetherlands"
   %red = 92 
   %green = 92
   %blue = 92
Return

Sub ChangeBackdrop
   SetWorld $world
   Backdrop $backdrop
   BackdropColor %red %green %blue
   ChangeAttributes
Return


Example 4

An example using time variables to change the backdrop and background colour at set times of the day:

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
var $world, $backdrop
var !now, !dawn, !day, !dusk, !night
var $time
var %red, %green, %blue
   # set your world name and times
   $world = "xelagon"
   GetTime   !dawn 5 
   GetTime   !day 8 30
   GetTime   !dusk 19 15
   GetTime   !night 21

   # cast the time variables into strings
   # and announce the times of change of attributes
   gettime $a !dawn 
   concat $a "Dawn at " $a
   say $a
   gettime $a !day
   concat $a "Day at " $a
   say $a
   gettime $a !dusk 
   concat $a "Dusk at " $a
   say $a
   gettime $a !night 
   concat $a "Night at " $a
   say $a
   $time = ""

   # start the main loop
   label Loop
      GetTime !now
      IfTime      !now IsBetween !dawn  !day   Gosub dawn
      Else IfTime !now IsBetween !day   !dusk  Gosub day
      Else IfTime !now IsBetween !dusk  !night Gosub dusk
      Else IfTime !now IsBetween !night !dawn  Gosub night
   goto Loop

# end of main body
End

# the subs

Sub dawn
   IfString $time = "dawn"  EndSub
   $time = "dawn"
   say and it is dawn at {hour}:{minute}
   $backdrop = "softskydawn"
   %red = 92 
   %green = 92
   %blue = 92
   gosub ChangeBackdrop
EndSub

Sub day
   IfString $time = "day"  EndSub
   $time = "day"
   say and it is day at {hour}:{minute}
   $backdrop = "softskyday"
   %red = 255 
   %green = 255
   %blue = 92
   gosub ChangeBackdrop
EndSub

Sub dusk
   IfString $time = "dusk"  EndSub
   $time = "dusk"
   say and it is dusk at {hour}:{minute}
   $backdrop = "softskydusk"
   %red = 120 
   %green = 92
   %blue = 120
   gosub ChangeBackdrop
EndSub

Sub night
   IfString $time = "night"  EndSub
   $time = "night"
   say and it is night at {hour}:{minute}
   $backdrop = "softskynight"
   %red = 32 
   %green = 32
   %blue = 32
   gosub ChangeBackdrop
EndSub

Sub ChangeBackdrop
   SetWorld $world
   Backdrop $backdrop
   BackdropColor %red %green %blue
   ChangeAttributes
EndSub


Example 5

Similar to example 4, but using string lists retrieved from file, as well as using time variables to change the backdrop and background colour at set times of the day:

[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
var $world
var !now, !dawn, !day, !dusk, !night
var $time
var /s_Attrib, $AttribFile
   # set your world name and times
   $world = "xelagon"
   GetTime   !dawn 5 
   GetTime   !day 8 30
   GetTime   !dusk 19 15
   GetTime   !night 21

   # cast the time variables into strings
   # and announce the times of change of attributes
   gettime $a !dawn 
   concat $a "Dawn at " $a
   say $a
   gettime $a !day
   concat $a "Day at " $a
   say $a
   gettime $a !dusk 
   concat $a "Dusk at " $a
   say $a
   gettime $a !night 
   concat $a "Night at " $a
   say $a
   $time = ""

   # start the main loop
   label Loop
      GetTime !now
      IfTime      !now IsBetween !dawn  !day   Gosub dawn
      Else IfTime !now IsBetween !day   !dusk  Gosub day
      Else IfTime !now IsBetween !dusk  !night Gosub dusk
      Else IfTime !now IsBetween !night !dawn  Gosub night
   goto Loop

# end of main body
End

# the subs

Sub dawn
   IfString $time = "dawn"  EndSub
   $AttribFile = "xelagon_dawn.txt"
   gosub ChangeBackdrop
   IfInt %i <> 0 EndSub
   $time = "dawn"
   say and it is dawn at {hour}:{minute}
EndSub

Sub day
   IfString $time = "day"  EndSub
   $AttribFile = "xelagon_day.txt"
   gosub ChangeBackdrop
   IfInt %i <> 0 EndSub
   $time = "day"
   say and it is day at {hour}:{minute}
EndSub

Sub dusk
   IfString $time = "dusk"  EndSub
   $AttribFile = "xelagon_dusk.txt"
   gosub ChangeBackdrop
   IfInt %i <> 0 EndSub
   $time = "dusk"
   say and it is dusk at {hour}:{minute}
EndSub

Sub night
   IfString $time = "night"  EndSub
   $AttribFile = "xelagon_night.txt"
   gosub ChangeBackdrop
   IfInt %i <> 0 EndSub
   $time = "night"
   say and it is night at {hour}:{minute}
EndSub

Sub ChangeBackdrop
   %i = -1
   GetWorld $w
   IfString $w <> $World EndSub
   SListLoad /s_Attrib $AttribFile %i
   IfInt %i = 0 ChangeAttributes /s_Attrib
EndSub

The files containing the world attributes must be in the same directory as the script. They look like this:

xelagon_dawn.txt

Backdrop=softskydawn
BackdropRed=92
BackdropGreen=92
BackdropBlue=92

xelagon_day.txt
Backdrop=softskyday
BackdropRed=255
BackdropGreen=255
BackdropBlue=92

xelagon_dusk.txt
Backdrop=softskydusk
BackdropRed=120
BackdropGreen=92
BackdropBlue=120

xelagon_night.txt
Backdrop=softskynight
BackdropRed=32
BackdropGreen=32
BackdropBlue=32


backIndex