ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Problems with updating (Sdk)
Problems with updating // SdkununduilNov 18, 2002, 1:48am
AW_AVATAR_CHANGE is not being re-called after a citizen bounces,
When a citizen first enters it can pick up all the changes being made but after the citizen leaves and reenters , the bot does not detect any changes (like avatar changes). Do I need to refresh? If so how? baronNov 18, 2002, 4:05am
The "refresh" is done by periodically calling aw_wait, usually through a timer; a couple times a second should be sufficient in most cases. http://www.activeworlds.com/sdk/aw_wait.htm
-Baron [View Quote] ununduilNov 19, 2002, 10:00pm
no its not that the call backs are getting messed up , there are no call
backs being used what I am trying to do is restrict anyone but my citizen number from using avatar 3 I have done the check when they enter or when it detects an avatar changes it can catch both no problem but if they leave the world and come back in it is almost like they get ignored now by the bot, and it does not pick up any avatar changes. if you want I can post the code if you think that will help.... [View Quote] baronNov 20, 2002, 4:07am
If the avatar leaves the world and comes back the event you are looking for is not AW_EVENT_AVATAR_CHANGE, it's AW_EVENT_AVATAR_ADD and you need to check the AW_AVATAR_TYPE attribute in its content; check http://www.activeworlds.com/sdk/AW_EVENT_AVATAR_ADD.htm. My guess is you maintain some sort of session table which you don't update during the above events and AW_EVENT_AVATAR_DELETE
-Baron [View Quote] ununduilNov 21, 2002, 1:50am
I am also checking AW_AVATAR_ADD,
but I am not maintaining a session table I am merely getting the session as they change and altering the AV if needed. Should I be maintaining a session table haha sorry first time with the SDK, still learning the IN's and OUT's of it. But I do appreciate all the help. [View Quote] baronNov 21, 2002, 7:45pm
Um nope, you don't need a session table for the task in hand, it was just a remote guess. A little more information on the language you use and maybe some (pseudo)code would be helpful since I'm out of ideas now. For example if it's VB and if you don't use Option Explicit, AW_AVATAR_ADD is not a syntax error but it's a dang logic error, the correct is AW_EVENT_AVATAR_ADD. Anyway I can't think of anything else as it is, sorry :)
-Baron [View Quote] ununduilNov 22, 2002, 8:13pm
Here is the code with, the citnumber world and PrivPass are garbage
*obviously* maybe I am overlooking something really dumb... god I hope so lol #include "aw.h" #include <stdio.h> #include <stdlib.h> void handle_avatar_add (void); void handle_avatar_change (void); void handle_avatar_delete (void); void set_avatar(int session,int type,int gesture); main (int argc, char *argv[]) { int rc; /* check command line if (argc < 3) { printf ("Usage: %s number password\n", argv[0]); exit (1); }*/ if (rc = aw_init (AW_BUILD)) { printf ("Unable to initialize API (reason %d)\n", rc); exit (1); } aw_event_set (AW_EVENT_AVATAR_ADD, handle_avatar_add); aw_event_set (AW_EVENT_AVATAR_CHANGE, handle_avatar_change); aw_event_set (AW_EVENT_AVATAR_DELETE, handle_avatar_delete); if (rc = aw_create (0, 0, 0)) { printf ("Unable to create bot instance (reason %d)\n", rc); exit (1); } //aw_int_set (AW_LOGIN_OWNER, atoi (argv[1])); aw_int_set (AW_LOGIN_OWNER, 12345678); //aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]); aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, "wouldn't you like to know"); aw_string_set (AW_LOGIN_APPLICATION, "Bot"); aw_string_set (AW_LOGIN_NAME, "Bot"); aw_bool_set (AW_ENTER_GLOBAL,true); if (rc = aw_login ()) { printf ("Unable to login (reason %d)\n", rc); exit (1); } if (rc = aw_enter ("beta")) { printf ("Unable to enter world (reason %d)\n", rc); exit (1); } aw_int_set (AW_MY_X, 1000); /* 1W */ aw_int_set (AW_MY_Z, 1000); /* 1N */ aw_int_set (AW_MY_YAW, 2250); /* face towards GZ */ if (rc = aw_state_change ()) { printf ("Unable to change state (reason %d)\n", rc); exit (1); } while (!aw_wait (-1)) ; aw_destroy (); aw_term (); return 0; } void handle_avatar_add (void) { aw_state_change (); char message[256]; sprintf (message, "Hello %s, welcome to beta",aw_string (AW_AVATAR_NAME)); aw_whisper (aw_int (AW_AVATAR_SESSION), message); printf ("avatar_add: %s %d\n", aw_string (AW_AVATAR_NAME),aw_int(AW_AVATAR_SESSION)); if (aw_int(AW_AVATAR_CITIZEN) != 12345678 && aw_int(AW_AVATAR_TYPE) == 3) { set_avatar(aw_int (AW_AVATAR_SESSION),0,0); } } void set_avatar (int session, int type, int gesture) { aw_int_set (AW_AVATAR_TYPE, type); aw_int_set (AW_AVATAR_GESTURE, gesture); if (aw_avatar_set (session)) printf ("Unable to set avatar for session %d\n", session); else printf ("Set avatar for session %d\n", session); } void handle_avatar_change (void) { if (aw_int(AW_AVATAR_CITIZEN) != 12345678 && aw_int(AW_AVATAR_TYPE) == 3) { set_avatar(aw_int (AW_AVATAR_SESSION),0,0); } } void handle_avatar_delete (void) { printf ("%s has left the scene\n", aw_string (AW_AVATAR_NAME)); } baronNov 22, 2002, 9:30pm
I don't get it, it seems to work fine for me; entered, changed avatar, bounced, changed avatar, bounced, changed avatar, all events received and handled. Just add 'printf ("avatar_change: %s %d\n", aw_string(AW_AVATAR_NAME),aw_int(AW_AVATAR_SESSION));' or something of the kind in your handle_avatar_change and you'll see you receive all events fine. One note, http://www.activeworlds.com/sdk/aw_avatar_set.htm needs world server build 44 but in any case it is called in the content of both ADD and CHANGE event handlers; must be gremlins.
-Baron [View Quote] ununduilNov 23, 2002, 5:39am
Bloody hell, at least I know I am not crazy lol thanx for all your help, I
realize the world server stuff but maybe that was it. |