backIndex

Xelagot action script

Events: TextComplete

Refer to Events for general information.

This event is triggered when the bot has finished saying a text set with SayText, WhisperText, ReplyText, ReplySText, ReplyWText. See the sections on Say, String lists and Text for usage.

Installer: OnTextCompleteEvent <eventlabel>
Event type: 5000

Specific statements (must be inside this event handler):

GetEventType %a stores the event type code in variable %a
GetEventResult %a stores the event result code in variable %a. 0 means success, -1 means text (whisper) aborted due to departure of avatar.
GetMessage $g SayText and WhisperText can set an optional last parameter: tag. This tag can be retrieved with GetMessage $g
GetTargetName $a The name of the avatar to whom the text was adressed is stored in $a. Only meaningfull if target is defined.
GetTargetSession %a The session number of the avatar to whom the text was adressed is stored in %a. Only meaningfull if target is defined.
GetTargetPerson &p The data of the avatar to whom the text was adressed are stored in &p. This includes name and session number. Only meaningfull if target is defined.
IfTargetDefined statement1
[Else statement2]
tests whether the target person is defined. i.e. if the text was addressed to a person. If defined, executes statement1. Otherwise, optionally, executes statement2
IfTargetUndefined statement1
[Else statement2]
tests whether the target person is not defined, i.e., if the text was not addressed to a person. If not defined, executes statement1. Otherwise, optionally, executes statement2

Example: the bot says its text and waits until it finishes. In the event handler for TextComplete it recovers the message corresponding to that text and says it aloud, and then ends the script with 'Do End'. Notice that, if you leave out 'Goto Mainloop', the script ends inmediately and the text will be said anyway, because the text buffer and the code saying the text are independent of the script: but you will not receive the TextComplete event.

[Head]
Type=Script
Version=2.0

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

[Script]
  OnTextCompleteEvent TComplete
  SayText 1 Laws "from Handbook of Robotics, 56th Edition, 2058 A.D."
Label MainLoop
  Goto MainLoop
End

Event TComplete
  GetMessage $g
  SayConcat "Finished reading text " $g
  Do End
EndEvent

Text Laws
The Three Laws of Robotics are:
1. A robot may not injure a human being, or, through inaction, allow a human being to come to harm.
2. A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.
3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.
EndText


backIndex