backIndex

Xelagot action script

Events: WorldEnter, WorldExit, WorldDisconnect.

(WorldReconnect is now obsolete, see below)

Refer to Events for general information.

WorldEnter is triggered when the bot enters a world successfully and when a bot re-enters a world after a disconnection, WorldExit when it exits a world. World Disconnect is triggered whenever the bot gets disconnected or ejected from the world.

WorldReconnect is now obsolete (X1 2.9999980, Av99/SrvcXlgBot 2.980 and higher) and should not be used in new scripts. It was not directly supported by the SDK, and tried to catch all possible re-connection signs, especially when the bot receives the world attributes (a sign it 'entered' the world). It was triggered by the bot whenever the bot recognised it has recovered from a waiting for server (wfs) or net congestion situation inside a world. This function is now obsolete because the bot explicitely leaves the world (and if necessary, the universe) when disconnected, and tries to reconnect periodically: its functionality has been taken over by OnWorldEnter. Both OnWorldEnter AND OnWorldReconnect are synonyms now and are triggered by the same event (that is, when the bot enters a world), to try not to break older script code: use OnWorldEnter in newer scripts. Note: if a script has both OnWorldEnter and OnWorldReconnect events installed, the last one installed is the valid one because both expressions are now equivalent. If a script uninstalls any of them, the event stops being handled in the script.

See also IfLoginUniverse, IfLoginWorld, IfWaitingForServer, IfWaitingForWorld, IfWaitingForUniverse.

Installers:

OnWorldEnterEvent <eventlabel>
Event type: 6200

OnWorldExitEvent <eventlabel>
Event type: 6300

OnWorldDisconnectEvent <eventlabel>
Event type: 6000

OnWorldReconnectEvent <eventlabel>
(obsolete, is now the same as OnWorldEnter) Event type was: 6100, is now 6200

Specific statements (must be inside the 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, other positive codes are equivalent to the rc codes of the SDK and the Windows codes. In the case of a disconnection, the code will be > 0, in the case of a reconnection, the code is always 0. See SDK Error Codes.

Example 1.

To wait for the bot to arrive in a world before proceeding with the script, Hambots have a WaitForBot command. Xelagots lack this statement, but have the WorldEnter event instead. For example:

#declare and initialise your variables
var %WaitForBot
%WaitForBot = 0
# install the event handler
OnWorldEnterEvent WorldEnter

# somewhere in the script, before entering or warping
%WaitForBot = 1
# ... your warp code here, then
Label WaitForBot1
IfInt %WaitForBot = 1 Goto WaitForBot1

# in the events and subs section
Event WorldEnter
   %WaitForBot = 0
EndEvent

Example 2.

When the bot does a property query, a disconnection stops the query for good: the event QueryComplete never occurs. To make sure that the bot completes the query use the WorldEnter event (x1 2.9999980):

#declare and initialise your variables
var @QueryPos, %IsQuerying
%IsQuerying = 0

# in your code, initialise @QueryPos,
# for example, get the bot's position
GetLocation @QueryPos
# install the event handlers
OnQueryCompleteEvent Complete
OnWorldEnterEvent Reconnect
# start your query
%IsQuerying = 1
QueryAt @QueryPos
# you will probably want to loop here until QueryComplete
Label WaitForQuery
IfInt %IsQuerying = 1 Goto WaitForQuery


# in the events and subs section
Event Complete
   %IsQuerying = 0
EndEvent

Event Reconnect
   IfInt %IsQuerying = 1 QueryAt @QueryPos
EndEvent


backIndex