Thread

VB, query and disconnects (Bots)

VB, query and disconnects // Bots

1  |  

henrikg

Sep 26, 2001, 5:38am
Hello, I've just started looking at bot programming and since I already had
VB started using the GrimmSoft wrapper.

My bot will listen to object clicks, and based on whats stated on the
description field will change other objects. This is an example of how it
works: A "target" objects will have in its description field:
"targer:lamp1". A "trigger" object will have "command(lamp1)create light".
When a user clicks the command object the bot update the action field of the
target object(s) with "create light".

The purpose is, of course, to have these kind of events be seen by all
avatars present.

When the object is first started is does a aw_query and store this
information in an array for later comparison. To handle updates I have
handles for object add and delete. The code is based on the query example on
GrimmSofts page. All this works great, except when the bot have a
disconnect, then it won't receive object add events anymore. Browsing
through this NG it seems people have solved this, but not really saying
how:) Anyone knows how this can be done? How do I for instance force a
re-query?

Any help is appreciated.

HenrikG

grimble

Sep 26, 2001, 12:23pm
I haven't looked at the SDK for a little while, and there have been a couple
of changes since I last used it, but based on my "old" knowledge, your
safest bet would definitely be to do a requery when it reconnects.

All you need to do is to retain the values in the 3x3 sector sequence number
array you used in your initial query instead of initialising them to zero.
Restart the query process again using the aw_query call (AwQuery the last
time I looked at the VB SDK) using the same center sector X and Z
corrdinates and all the event and callback handlers will be called again as
before. The entire contents of any cells that have changed since the
sequence number was last set (the previous aw_query) will be notified to the
bot.

The main drawback of this approach (not that I think there are any
alternatives short of repeating the full query) is that aw_query only
notifies the bot about objects that ARE there at the time of the query.
Where you are deleting objects, you need to bear in mind that if you don't
get an update for an object in a cell that has changed, then the object has
been deleted. In the past, I have done one of two things on receipt of an
AW_EVENT_CELL_BEGIN in a requery:

** Thrown away the entire store for the previous cell contents and rebuilt
it from the new events raised.

** Flagged all the objects in the cell store as "Unconfirmed", matched the
objects returned from the aw_query against the cell store using the
object_number updating them to "Confirmed" (or obviously adding a new one if
there's no matching objecting) and then dropped all "Unconfirmed" objects
when I get the AW_EVENT_CELL_END event.

One solution is quick and dirty (nothing wrong with that) but the other IMHO
is neater, faster and more true to what you are trying to do.

Also, I imagine you have this covered already, but I always used a
AW_EVENT_WORLD_ATTRIBUTES event to signify that the bot had reconnected to
the world after the AW_EVENT_WORLD_DISCONNECT event.

If some of this is obsolete now, apologies, but I don't imagine that AW
would have radically changed the way such a fundamental bot process would
work.

Hope this helps,

Grims.



[View Quote]

henrikg

Sep 26, 2001, 3:44pm
Thanks grimble, I found it easier to follow the "brute force" route and
re-query the whole sector. Once I've read your reply I knew it would be
possible, but its not documented anywhere I've seen _how_ to do this. After
messing with it awhile I discovered resetting all the Sequence-array numbers
to 0, I could query everything again.

Thanks again, the poor hardworking bot is working now :)

Henrik

PS I agree a more elegant method is prefered, but I don't trust my sdk
skills yet to try it..hehe DS

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