backExamples

Xelagot action script

Mirror Bot

You can download this script: click here.

[Head]
Type=Script
Version=2.0

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

[Script]

                         ###################################
                         #         The Mirror Bot          #
                         #        a Xelagot script         #
                         # (c) 1999 Alex Grigny de Castro  #
                         ###################################

var @Mirror, @Person, %Distance, %Depth, %Radius, %Height
var %Owned, %DefAv
var $Sp

######################################################
# write the position here, including the way it faces
# (altitudes are in meters, not in AW units)
######################################################
@Mirror = 0.000n 1.000e 0.00a 270 

######################################################
# next is the default avatar (when nobody is using it)
######################################################
%DefAv = 0

######################################################
# the text the bot whispers,
# after saying the name of the person
######################################################
$Sp = ", let me be your mirror, try our avatars and gestures :-)"


warplocal @Mirror

%Distance = 5
%Radius = 4
%Height = 1.5
%Depth = 0.5

@Person = @Mirror
LocMove3D @Person %Distance 0 0
LocMove3D @Person %Depth 0 -90
LocTurn @Person 180
%Owned = 0
Avatar %DefAv
OnAvatarAddEvent Change
OnAvatarChangeEvent Change
OnAvatarDeleteEvent Delete
OnWorldDisconnectEvent WFS
Label Loop
goto Loop

End

Event Change
   GetAvatarPerson &p
   GetSession %s &p
   IfInt %Owned = 0 Gosub Free
   Else IfInt %Owned = %s Gosub Owned
EndEvent

Event Delete
   GetAvatarPerson &p
   GetSession %s &p
   IfInt %Owned <> %s EndEvent
   %Owned = 0
   Gosub Owned
EndEvent

Event WFS
   IfInt %Owned = 0 EndEvent
   %Owned = 0
   Gosub Owned
EndEvent

Sub Free
   IfLoc &p IsInVCylinder @Person %Radius %Height %Owned = %s
   IfInt %Owned = 0 EndSub 
   GetName $n &p
   Concat $a $n $Sp
   Whisper &p $a
   Gosub Mirror
EndSub

Sub Owned
   IfInt %Owned <> 0 IfLoc &p IsInVCylinder @Person %Radius %Height Gosub Mirror
   Else %Owned = 0
   IfInt %Owned = 0 Avatar %DefAv
   IfInt %Owned = 0 WarpLocal @Mirror
EndSub

Sub Mirror
   GetAvatar %a &p
   GetGesture %g &p
   GetRotation %p &p
   GetPosition @p &p
   LocTurn @p @Mirror
   GetRotation %n @p
   Sbt %x %n %p

   @m = @Mirror
   LocTurn @m @p
   LocTurn @m %x
   Avatar %a
   Gesture %g
   WarpLocal @m
EndSub



backExamples