backIndex

Xelagot action script

User input and output

Various commands allow user input and output of data.

User input may be achieved by calling an input form. The syntax is:

Input $title $comment $default $button
InputSecret $title $comment $default $button

The form caption is set by the contents of $title, a comment is set with $comment, $default is a default input string and $button defines the text on the exit button.

Input shows the input text on the form, InputSecret shows * symbols (use for inputting passwords).

The input string may be collected in a string variable with the following statement:

GetInput $a

Two ways of implementing a user input

  1. Simply by calling the form, and collecting the string when the form closes. In this case, the execution of the script is interrupted until the form closes. No events are handled while the form is open.
    [Head]
    Type=Script
    Version=2.0
    
    [Settings]
    Origin=0.000n 0.000w 0.00a 0.0°
    
    [Script]
    Input "Input" "Type in what the bot must say:" "Hi all of you!" "Ok"
    GetInput $a
    Say $a
    End
    
  2. By installing an event handler for the the input, see Events: Input. In this case, the script carries on executing while the form is open, events are normally trapped. The form triggers an event upon closing.
    [Head]
    Type=Script
    Version=2.0
    
    [Settings]
    Origin=0.000n 0.000w 0.00a 0.0°
    
    [Script]
       $a = ''
       %b = 0
       OnInputEvent MyInput
       InputSecret "Input" "Type in your privilege password:" "" "Done!"
       label loop
          # the code in this loop will be executed
          # until the form closes
          # and the event is triggered
       ifInt %b = 0 goto loop
       # here some more code that uses the password
       # for instance to log in the bot
       # make sure the bot is not logged in
       Void
       # set the necessary data
       UniverseData "Active Worlds" "" 0
       CitizenData 289499 "XelaG" $a
       BotName "MyBot"
       @w = "20n 5w 0a 90: xelagon"
       # log in
       Warp @w
    End
    
    Event MyInput
       GetInput $a
       %b = 1
    EndEvent
    

Usage within an event handler

Any code following an Input or InputSecret statement in an event handler is ignored. These statements must always be the last ones if used within an event handler. There are 2 solutions for retrieving the input string:

  1. if you don't want to install an event handler, put a ResetTo label statement before the Input or InputSecret call, pointing to a label in the main body
  2. before the Input or InputSecret call, install an event handler for the input form, with a statement such as OnInputEvent InputA, and a corresponding event handler called Event InputA where you can collect the input string.

User output has the following statements:

UserMsg $a Opens a message window and prints string $a in bold letters.
UserMsgHigh $a Opens a message window, prints string $a in bold letters and changes the icon to a flashing icon. The icon will stop flashing when you click on the window.
UserMsgLow $a Opens a message window and prints string $a in normal letters.
UserMsgOpen Opens an empty message window.
UserMsgClose Closes the message window. Normally, this will be done by the user by clicking on the 'close' icon, not using this statement.


backIndex