Aw object click

From ActiveWiki
Jump to: navigation, search
Minimum requirements
Added in version 2.2
SDKbuild 14
Worldbuild 21
Browserbuild 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:

There is also new method which was introduced in version 4.1:

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

AW_OBJECT_NUMBER
AW_OBJECT_X
AW_OBJECT_Z
AW_OBJECT_ID
AW_OBJECT_SYNC
AW_OBJECT_SESSION_TO

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);
}

See also