These events are triggered when an avatar (the source) clicks on
an object (the target). ObjectClick is triggered by a
left-click, Object Select by a right-click.
In these event handlers, you must test whether the target is defined or not if you need the target, and exit if it is not:
These events are meaningful only if the bot has finished a property query and is in live update, and the object clicked on is within the queried zone. See Events: QueryBegin, QueryComplete.
Installer: OnObjectClickEvent <eventlabel>
Event type: 700
Installer: OnObjectSelectEvent <eventlabel>
Event type: 800
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. See SDK Error Codes.|
|GetSourceName $a||The name of the avatar causing this event is stored in $a|
|GetSourceSession %a||The session number of the avatar causing this event is stored in %a|
|GetSourcePerson &s||The data of the avatar causing this event are stored in &s. This includes name and session number.|
|GetTargetObject ~t||The data of the object clicked on are stored in ~t.|
|GetSourceTarget &s ~t||The data of both the source person and the target object are
stored in &s and ~t. AvatarClick uses a
GetSourceTarget &s &t
|tests whether the target object is defined. If defined, executes statement1. Otherwise, optionally, executes statement2|
|tests whether the target object is not defined. If not defined, executes statement1. Otherwise, optionally, executes statement2|
An example, where the bot detects object clicks and selects from everyone.
[Head] Type=Script Version=2.0 [Settings] Origin=0.000n 0.000w 0.00a 0.0° [Script] Label Top OnObjectClickEvent OnObjectSelectEvent OnWorldReconnectEvent Reconnect # install event handler for end of query OnQueryCompleteEvent QueryEnd # get bot location for query GetLocation @a # start query Say Starting query, please wait... QueryAt @a Label Loop1 # loop until query is complete Goto Loop1 Label Start2 # unintstal event handler for query OnQueryCompleteEvent # install event handler # for ObjectClick and ObjectSelect # in the same handler OnObjectClickEvent ObjectClickSelect OnObjectSelectEvent ObjectClickSelect # loop forever Label Loop2 Goto Loop2 End Event QueryEnd # announce end of query Say Query completed, start clicking # reset main pointer to label Start2 ResetTo Start2 EndEvent Event ObjectClickSelect # get event data IfTargetUndefined EndEvent GetEventType %e GetSourcePerson &p GetName $n &p GetTargetObject ~j GetModel $m ~j # check if it is a click or a select IfInt %e = 700 SayConcat $n " clicked on " $m " at " ~j Else SayConcat $n " selected " $m " at " ~j WarpLocal ~j EndEvent Event Reconnect # was disconnected, # start querying again ResetTo Top EndEvent