backExamples

Xelagot action script

PA System Bot

Requires knowlegde of how to connect bot clients to a xelagot server, and assumes connection has been established.

Creates a system of microphones and speakers to broadcast messages at different locations, worlds or universes simultaneously. A bot can act as both microphone and speaker, or only as speaker (omit its name from the Bots.txt file). Was tested and used successfully as PA system at the Avatars2000 event in ActiveWorlds, October 15th 2000.

Read the initial comments carefully. You will need to create a directory in the Script directory, and put two auxiliary files in it: Permissions.txt and Bots.txt. The script itself can be elsewhere. It must be loaded by all bots participating in the system.

Download the script: announce.zip

[Head]
Type=Script
Version=2.0

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

[Script]
############################################################################
#                               PA SYSTEM BOT
#                            used in Avatars2000
#                            October 15th,  2000
#              (c) Copyright 2000 Alex Grigny de Castro (XelaG)
############################################################################
# Requires all bots participating to have their Bot Clients
# connected to a xelagot server with Bot protocol
# (this script assumes the connection has been established)
#
# Needs two files in the Script\Announce directory (which must be created),
# with entries on separate lines:
# Permissions.txt contains the names of the ppl or bots allowed to broadcast
# (bot names must be in square brackets, as trapped in the Chat event handler)
# Bots.txt contains the LOGIN name of the bots acting as speakers (no brackets)
#
# To broadcast a <message>, say or whisper:
# /bc <message>
#
# To call the bot's attention, say:
# /bc
# the bot whispers back:
# Whisper: /bc <message>
#
# A Central client logged into the system can also broadcast through the
# (1) WriteToBot "hear" channel (requires Master protocol)
#     (button caption: Chat)
# (2) Message channel (requires Bot protocol only)
#     (button caption: AS Message)
############################################################################

var $MyName
var $Login, $chat, %Etype, $Msg
var &Person
var $PermissionsFile, /s_Perm
var $BotsFile, /s_Bots, %Bots
var $AnA, $AnB, %AnI, %AnC, %Done, %chatType

  GetName $MyName
  GetScriptDir $d
  Concat $d $d "Announce\"
  Concat $PermissionsFile $d "Permissions.txt"
  Concat $BotsFile $d "Bots.txt"
  OnChatEvent Chat
  OnCLMessageEvent CLMessage
  OnCLHearEvent CLMessage

  Gosub InitAnnounce
Label MainLoop
  Goto MainLoop
End

Sub InitAnnounce
  SListLoad /s_Perm $PermissionsFile
  SListNoBlanks /s_Perm
  SListLoad /s_Bots $BotsFile
  SListNoBlanks /s_Bots
  SListGetCount /s_Bots %Bots
EndSub

Event Chat
  %ChatType = 1
  GetEventType %EType
  GetChatPerson &Person
  GetChatName $Login
  GetChatLine $chat
  %Done = 0
  IfString "/bc" IsIn $Chat IfSListGetString /s_Perm $Login %c Gosub Announce
  IfString "reload" = $chat IfPerson $p IsBoss Gosub InitAnnounce
EndEvent

Event CLMessage
  %ChatType = 0
  GetEventType %EType
  GetEventLogin $Login
  GetMessage $chat
  %Done = 0
  IfString "/bc" IsIn $Chat IfSListGetString /s_Perm $Login %AnC Gosub Announce
  IfInt %Done > 0 EndEvent
  IfString "-say " IsIn $Chat IfSListGetString /s_Bots $Login %AnC Gosub SayIt
  IfInt %Done > 0 EndEvent
EndEvent

Sub SayIt
  %Done = 0
  Split $AnA $AnB $chat "-say "
  Trim $AnB $AnB
  IfString $AnB = "" EndSub
  %Done = 1
  Say $AnB
EndSub

Sub Announce
  %Done = 1
  IfString $chat = "/bc" IfInt %ChatType = 1 WhisperConcat &Person "Whisper: /bc "
  IfString $chat = "/bc" EndSub
  %Done = 0
  Split $AnA $AnB $chat "/bc "
  Trim $AnB $AnB
  IfString $AnB = "" EndSub
  %Done = 1
  Say $AnB
  Concat $AnB "-say " $AnB
  %AnI = 1
Label AnnounceLoop
  IfInt %AnI > %Bots Goto AnnounceEnd
  SItemGet /s_Bots %AnI $AnA
  IfString $AnA <> $MyName CLWrite $AnA $AnB
  Inc %AnI
  Goto AnnounceLoop
Label AnnounceEnd
EndSub



backExamples