Confused? Know how to script but .... how do I use all this script jargon to have my bots communicate through internet?
First of all, one of the xelagot programs participating in the connection must set up and activate its Server. Read the pages on the Server/clients user interface: The Server must have a server connection list containing the Login names and passwords of each bot, and the protocol for each of these must be: bot or master (the old notation 'bot,master' is obsolete as from version 2.9999949). 'master' protocol is only needed by bots that must have access to the CLWriteToBot and AnyWriteToBot commands. To add an item to that list, right click on it to bring up a pop-up menu and click on add client.
Once the Server connection list is ready, the server can open a listening connection to allow bots to connect (Server/Clients user interface, menu Server | Connect).
To connect with a server, bots use their Bot Clients. Bot Clients can be set up and logged into the server from the Clients user interface, or from Action Scripts.
Bots can communicate with other bots if they are running Action Scripts containing the appropriate statements.
Here is an example of a script, which does not much more than open a connection for its Bot Client to a server with IP 18.104.22.168 and port 9000. The bot uses its own name to login, and has in this case no need for a password. The script must have the same IP and port number as used by the Server, and the Server must have a Server connection list which includes the name of the bot as Login name = the bot's name, no password, and protocol = bot.
[Head] Type=Script Version=2.0 [Settings] Origin=0.000n 0.000w 0.00a 0.0° [Script] var $MyLogin # install all bot-client events OnCLConnectEvent Connects OnCLLoginEvent LogsIn OnCLMessageEvent Reads OnCLDisconnectEvent Disconnects OnCLAddEvent OneMore OnCLDeleteEvent OneLess OnCLUnsent NotThere GetName $MyLogin ClHost "22.214.171.124" CLPort 9000 CLLogin $MyLogin CLPassword "" CLConnect Label MainLoop Goto MainLoop End Event Connects Secret Connected EndEvent Event LogsIn Secret Logged in # say hello to all clients CLWriteAll "hi :)" EndEvent Event Disconnects Secret Disconnected EndEvent Event Reads GetEventLogin $n GetMessage $a # tell the user what is heard Concat $b $n " says " $a Secret $b EndEvent Event OneMore GetEventLogin $n Concat $b $n " is online" Secret $b IfString $n <> $MyLogin CLWrite $n "welcome" EndEvent Event OneLess GetEventLogin $n Concat $b $n " goes offline" Secret $b EndEvent Event NotThere GetEventLogin $n GetMessage $a Concat $b "could not send to " $n " message: " $a Secret $b EndEvent
This script will only succeed if the Server is online. It is a very simple script, and uses most statements you will ever need. The statements in blue can even be omitted if you connect the Bot Client through the Clients user interface.
In practice, you would not use a script like this one: you would put the installers in a convenient place in a script of your own, and the event handlers would have some other statements as required by your script.
The communication between Bot Clients is done through the event handler CLMessage (installer OnCLMessageEvent, in this example Event Reads) for receiving messages, and with the statements CLWrite $n $a and CLWriteAll $a to send messages. In this example, the variable $n is used to store the Login name of the Bot Client communicating with your bot: GetEventLogin $n and CLWrite $n $a. The messages are stored in the variable $a: GetMessage $a and CLWrite $n $a. Of course, you will have to parse the GetMessage $a string (CLMessage event, here in Event Reads), in a similar way as you parse the GetChatline $a string in a Chat event.
Note 1: There are also the CLWriteToBot and AnyWriteToBot statements to send WriteToBot commands to bots (they require a master protocol). One of these commands is Message, which also triggers the CLMessage event. Another command, which works as a verbal command, is Hear, which can be trapped in the destination bot's CLHear event handler and gets processed by the Verbal Command processor. Answers to such a command are trapped by the one that issued the command in its CLAnswer event handler.
Note 2: Beware of cascading. If the bots respond with CLWrite or CLWriteAll to anything another bot says, you may end up cascading. The same applies to Chat events.