Aw object click
Minimum requirements | ||
---|---|---|
Added in version 2.2 | ||
SDK | build 14 | |
World | build 21 | |
Browser | build 296 |
int aw_object_click (void)
Description
Simulates clicking an object.
Callback
None (returns immediately)
Notes
This method triggers AW_EVENT_OBJECT_CLICK in all the neighbors that have subscribed to the event. It is intended for use by the Active Worlds Browser to indicate when a user clicks an object (by left-clicking on it with the mouse). However it is also available for use by SDK applications which may wish to simulate user mouse actions for the purposes of testing, etc.
The object to be clicked can be specified in two ways. This is the old method for doing it:
- AW_OBJECT_X is set to x coordinate of object (in cm's).
- AW_OBJECT_Z is set to z coordinate of object (in cm's).
- AW_OBJECT_NUMBER is set to object number (which is only unique to all objects within the same cell).
- AW_OBJECT_ID is set to 0.
There is also new method which was introduced in version 4.1:
- AW_OBJECT_X is not used.
- AW_OBJECT_Z is not used.
- AW_OBJECT_NUMBER is set to 0.
- AW_OBJECT_ID is set to the object id (which is unique to all objects within the world).
The attribute AW_OBJECT_SYNC can be set to 1 (true) if the object click should be propagated to all neighbors within range. This has the same effect as a user clicking on building commands that have a 'global' parameter. If this is not desired then set AW_OBJECT_SYNC to 0 (false).
For world build 95 or later, and SDK build 75 and later: The attribute AW_OBJECT_SESSION_TO can be set to the recipient. Only the specified session will recieve AW_EVENT_OBJECT_CLICK.
Arguments
None
Argument attributes
Return values
- RC_SUCCESS
- RC_NOT_INITIALIZED
- RC_NO_INSTANCE
- RC_NO_CONNECTION
- Network connection to the world is down.
Returned attributes
- AW_OBJECT_SYNC
- Is set to 0.
- AW_OBJECT_SESSION_TO
- Is set to 0.
Usage
Simulate a left-click on an object.
void click_object (int x, int z, int number, int id) { int rc; aw_int_set (AW_OBJECT_ID, id); aw_int_set (AW_OBJECT_SYNC, 0); aw_int_set (AW_OBJECT_NUMBER, number); aw_int_set (AW_OBJECT_X, x); aw_int_set (AW_OBJECT_Z, z); rc = aw_object_click (); if (rc != RC_SUCCESS) printf ("Object click failed (reason %d)\n", rc); }