chris langton // User Search

chris langton // User Search

1  |  

Questions

Oct 10, 1998, 11:54am
Here are two *simple* event handlers for when an avatar does something in
the presence of your
bot: one for when an avatar changes state (e.g., does a gesture, moves...),
and the other for when an avatar emits a chat-line.

These are very simple - the point is that these event handlers are where
the execution comes when
something happens - and while you are in the handler, the varous attribute
variables will hold the
appropriate data (like the CHAT_STRING, or the GESTURE that caused the
events in the code
below)

You could do something specific in avatar-change to determine which
direction the av has
moved (by comparing its position to a previous position, for instance) or
to determine if
it is close (compare its X,Z position with your bot's.....) all of these
are done by accessing the
appropriate attribute variables within the event handler (e.g., AW_AVATAR_X
and AW_AVATAR_Z) - you could respond to the avatar's type (Butch, Lori,
whatever), by
checking the attribute AW_AVATAR_TYPE, so that, for instance, you could
greet it by its
AV name - you could greet it by its owner's citizen name by checking
AW_AVATAR_NAME..

__________________________________

/* An avatar has changed its state (moved, done a gesture, etc....) */
/* Just speak its gesture */
/* all of the AV's state attributes are valid here */

void handle_avatar_change (void)
{

char message[100];

sprintf (message, "Your gesture is: %i", aw_int (AW_AVATAR_GESTURE));
aw_say (message);
}


/* An avatar has said something */
/* just say it back */

void handle_chat (void)
{

char message[100];

sprintf (message, "You said: %s", aw_string (AW_CHAT_MESSAGE));
aw_say (message);

}

_________________________________________________________

And, of course, you have to register these event handlers in your main()
program:

aw_event_set (AW_EVENT_AVATAR_CHANGE, handle_avatar_change);
aw_event_set (AW_EVENT_CHAT, handle_chat);

(By the way - the avatar change handler will get called twice when an AV
executes a gesture,
because the AW system sends a "do gesture 0" after every gesture command,
so whenever you wave or do the Maca, for instance, the system issues a do
gesture 0 command immediately after,
you can see this happen with the above code....)

hope these help...


Chris Langton

aka
MockingBird

__________________________________________


[View Quote] > Ok got some questions...
>
> 1. can I make my bot respond to a gesture?
> if so can I get an example code in c
>
> 2. can I make my bot move in a foward in the direction a persons avatar
> is facing when they do something?
> if so can I get an example code in c
>
> 3. can I make my bot do something when an avatar gets close?
> if so can I get an example code in c

Reason code 200? - add object

Nov 18, 1998, 3:58pm
Hello..

I'm having a problem adding and changing objects....I'm using the code

exactly as listed in the documentation for aw_object_add and
aw_object_change.

I'm just trying to do something simple - create an object and move it
around....

When I attempt to add an object, the object appears in the world, with
all the
right attributes filled out, but I get "unable to add object (reason
200)"

I don't see reason 200 on the list, but I assume it has something to do
with permissions,
or something like that. I do have bot rights and building
rights...(eminent domain rights).
Restricted radius in the world is 0.

After that, when I attempt to change the object with the object number
returned in
AW_OBJECT_NUMBER and the X and Z coords, I get "Unable to change object
(reason 310)" (no build rights) and then the same error message with
reason 204
(can't find old element).

So - first step is to understand reason 200 - anybody know this one?

Second - I'm a bit unsure about why one needs to identify an object
with both
the object number *and* the X and Z coords - shouldn't the object number
alone
suffice? Or is it not guaranteed to be unique?


The code - (SDK calls look strange because I'm using the version for the
Gnu compiler )

// Create Object

Xcoord = 2000;
Zcoord = 2000;

altitude = 1000;
yaw = 0;

(AWIntSet) (AW_OBJECT_X, Xcoord);
(AWIntSet) (AW_OBJECT_Z, Zcoord);
(AWIntSet) (AW_OBJECT_Y, altitude);
(AWIntSet) (AW_OBJECT_YAW, yaw);

(AWStringSet) (AW_OBJECT_MODEL, "tree01.rwx");
(AWStringSet) (AW_OBJECT_DESCRIPTION, "PineTop Airways");

if (rc = (AWObjectAdd) ())
printf ("Unable to add object (reason %d)\n", rc);
else
puts ("Object added");

object = (AWInt) (AW_OBJECT_NUMBER);

// change object position

(AWWait) (5000);

for (i = 0; i<100; i++) {

deltaX = 1000; /* place holders - These will be random
displacements */
deltaZ = 1000;

(AWIntSet) (AW_OBJECT_OLD_NUMBER, object);
(AWIntSet) (AW_OBJECT_OLD_X, Xcoord);
(AWIntSet) (AW_OBJECT_OLD_Z, Zcoord);
(AWIntSet) (AW_OBJECT_X, Xcoord+deltaX);
(AWIntSet) (AW_OBJECT_Z, Zcoord+deltaZ);

Xcoord += deltaX;
Zcoord += deltaZ;

if (rc = (AWObjectChange) ())
printf ("Unable to change object (reason %d)\n", rc);
else
puts ("Object changed");

(AWWait) (1000);

}

Etc....

Any suggestions appreciated......

Thanks

Chris Langton
AKA MockingBird

Reason code 200? - add object

Nov 18, 1998, 5:04pm
<forehead slap> ooops - I missed that thread - thanks!

But I still don't understand why I'm getting the other errors - am I
misidentifying the object somehow?

MockingBird


[View Quote] > See the thread rc 200 above.
>
[View Quote]

Reason code 200? - add object

Nov 18, 1998, 5:08pm
[View Quote] > Changing an object is really destroying one object and building another
> object in its place (see the revised documentation for aw_object_change and
> AW_EVENT_OBJECT_ADD). Try filling in all the properties of the new object
> version, and see if that helps. (Number+x+z helps to find an object,
> certainly.)
>
> Also, why is aw_wait outside the construction loop?
>

Ahhh - so when I change the object I have to obtain a new object number via
AW_OBJECT_NUMBER? that would explain it.....

I have a wait between creating and changing, and then I have a wait in the loop
....
no good reason....!

Thanks

Mock

Reason code 200? - add object

Nov 19, 1998, 9:05pm
<sheepish grin>

Mea culpa all the way around, I'm afraid - I should have read the
sample program and docs more carefully....

Just to summarize, my problems were due to:

1) I did not understand that aw_object_change is effectively just
a concatenation of aw_object_delete and aw_object_add. I had
assumed that the object persisted through the change and that one
just had to specify the attributes that were being changed, the
other attributes being carried over without change.

2) <even more sheepish grin> I was, in fact, using an old build
of the SDK, which was the cause of the "reason 200" response.

So - thanks to Canopus and Roland for the clarifications....

Yours in livelier computing...

Chris Langton

AKA MockingBird




[View Quote] >
> Yes, this is correct. Take a close look at the second SDK sample
> application. You'll see at the bottom of the routine change_midi() the
> program saves the new value of AW_OBJECT_NUMBER after calling
> aw_object_change().
>
> I still don't understand how you were running into the rc 200 problem...that
> was fixed many builds ago. Were you just on an old build of the SDK?
>
> -Roland

AV98 New Mexico site...

Nov 18, 1998, 6:03pm
Hello!

We are hosting one of the Avatars98 face-2-face sites here in Santa
Fe New Mexico...

Anybody within a reasonable driving distance of Santa Fe is welcome to
attend!

Please email me (cgl at swarm.com) if you'd like to join us on Nov. 21...

Nobody has contacted me via the announcement on the AV98 web-site - is
there
anybody else here in New Mexico who is building worlds? Even if you
can't come
to the Nov. 21 event here, I'd like to hear from you....

Chris Langton

AKA MockingBird

supresing bot name [imabot] display

Nov 21, 1998, 12:56pm
I'm working on flocking bots and other animal-style behaviors, for which

I'd prefer that the bot name not appear above the avatar. These things
are just going
to move around in a lifelike way, not speak. The docs for AW_LOGIN_NAME
say that
the bot name will appear above the bot if it speaks - but it seems to
appear even
if the bot doesn't speak - is there a way to supress it appearing?

Chris Langton

AKA MockingBird

supresing bot name [imabot] display

Nov 24, 1998, 9:09pm
Right! that's it - great!

Thanks to Roland and veleno for the help, and to XelaG for the humor.....

Chris [iamnotabot] Langton

AKA MockingBird

[View Quote] > Bot names are only exposed to you if you are a world caretaker or if you
> have eject rights in that world. Other people will not see the names unless
> the bots speak..
>
> -Roland
>
[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn