ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
AwSDK 5x5 Query Worries (Sdk)
AwSDK 5x5 Query Worries // Sdkstrike rapierJul 2, 2002, 12:10am
Hello folks,
For a while now ive been attempting to create a 5x5 query for the new sdk, despite it being easier ive just not acomplished anything. Id really apreciate it if someone could point me towards a working demo of the new code so I can learn from it. - Mark grimbleJul 2, 2002, 1:33pm
Hmmm ... tried it (and a standard 3x3) and I can't get it to behave either
but then its been a long time since I've actually had to write query code (usually strip it from a library which I don't have for the COM wrapper). What are you using to populate the sequence number? I tried (with variations of) ... cellX = mAWSDK.aw_int(AW_CELL_X) cellZ = mAWSDK.aw_int(AW_CELL_Z) cellSequence = mAWSDK.aw_int(AW_CELL_SEQUENCE) sectorX = mAWSDK.aw_sector_from_cell(cellX) - QUERY_SECTOR_X + 2 sectorZ = mAWSDK.aw_sector_from_cell(cellZ) - QUERY_SECTOR_Z + 2 mAWSDK.aw_seq_5x5(sectorX, sectorZ) = cellSequence where QUERY_SECTOR_X and QUERY_SECTOR_Z are the centre sectors for the query, so the centre sector is in element 2. Maybe I'm missing something ... Not a very helpful post really I guess, sorry. Grims Grims [View Quote] milestegJul 2, 2002, 1:50pm
"grimble" <grimble2000NOSPAM at btinternet.com> a écrit dans le message de
news: 3d21c7e3$1 at server1.Activeworlds.com... > Hmmm ... tried it (and a standard 3x3) and I can't get it to behave either > but then its been a long time since I've actually had to write query code > (usually strip it from a library which I don't have for the COM wrapper). > > What are you using to populate the sequence number? I tried (with variations > of) ... > > cellX = mAWSDK.aw_int(AW_CELL_X) > cellZ = mAWSDK.aw_int(AW_CELL_Z) > cellSequence = mAWSDK.aw_int(AW_CELL_SEQUENCE) > > sectorX = mAWSDK.aw_sector_from_cell(cellX) - QUERY_SECTOR_X + 2 > sectorZ = mAWSDK.aw_sector_from_cell(cellZ) - QUERY_SECTOR_Z + 2 > mAWSDK.aw_seq_5x5(sectorX, sectorZ) = cellSequence > [CUT] I don t use VB Sdk , so i can t really help.. i just can guess :) maybe you can try swapping sectorZ and sectorX: mAWSDK.aw_seq_5x5(sectorZ,sectorX) = cellSequence in C sdk, it works that way :) Regards, MilesTeg billybobJul 2, 2002, 3:56pm
I thought for sure I had code for 5x5 query on my computer somewhere, but oh
well, I'll try to explain. To use the 5x5 query all you have to do is use the same example code given for the 3x3 query(on MrGrimm's site), change the sequence array size to fit a 5x5 query(0 to 4) and then change all 1's to 2's in the eventcellbegin sub. Changing the 1's to 2's is the most important part, btw. After that you should be right on your way to querying a 5x5 area. The method is also the same for C++. Extra Info: This is a nice trick I'm sure many people have already figured out, but here it is. What if you wanted a bot that runs in global mode and querys the entire world? No, global mode does not already query the entire world for you, but that doesn't matter. Just setup your bot in global mode, and then query the WHOLE world using the AwCellNext feature of the sdk. It should be explained on the AW SDK site and MrGrimm's site. Hope that helped. grimbleJul 2, 2002, 8:45pm
It used to be that way around with the OCX too, but now we don't have the 2D
array, the COM object does. The arguments are explicity named now, but I did try the "wrong" way around and a number of variations with no luck. No documentation to speak of at the moment, sadly for people to work it out. Grims [View Quote] grimbleJul 2, 2002, 8:49pm
This is for the COM wrapper not the AwSdkOcx5 control. There's no array in
the bot code anymore - its been taken out of the developers hands. The old control used to work pretty much the same as going directly to the sdk (same array orientation). The sample code on MrGrimms site refers to the OCX control and not the COM wrapper. Grims [View Quote] baronJul 8, 2002, 7:29pm
OK since there is no documentation and it's not expected anytime soon it makes sense to share; not sure if everything is working as expected since I just figured these out and tested them only a couple of times, sure seems like everything is in place. Set the FiveXFive flag to determine if you are going for 3x3 or 5x5 query, call QueryNow to get rolling. Please let me know if something is wrong before I update all my projects :)
=============================================== Option Explicit Dim FiveXFive as Boolean Dim sect_x As Long Dim sect_z As Long Dim cell_x As Long Dim cell_z As Long ---------------------------------------------------- Public Sub QueryNow() cell_z = 0 'or whatever cell_x = 0 'or whatever ' Set the sector to query sect_z = sdk.aw_sector_from_cell(cell_z) sect_x = sdk.aw_sector_from_cell(cell_x) ' Perform the query If FiveXFive = False Then sdk.aw_query sect_x, sect_z Else sdk.aw_query_5x5 sect_x, sect_z End If End Sub ---------------------------------------------------- Private Sub sdk_CallbackQuery(ByVal rc As Long) ' Continue the query until it is complete If Not sdk.aw_bool(AW_QUERY_COMPLETE) Then If FiveXFive = False Then sdk.aw_query sect_x, sect_z Else sdk.aw_query_5x5 sect_x, sect_z End If Exit Sub End If 'Do stuff here End Sub ---------------------------------------------------- Private Sub sdk_EventCellBegin() Dim X As Long Dim Z As Long If FiveXFive = False Then ' Get the current cell cell_x = sdk.aw_int(AW_CELL_X) cell_z = sdk.aw_int(AW_CELL_Z) ' Calculate the sector the cell is in X = sdk.aw_sector_from_cell(cell_x) - sect_x Z = sdk.aw_sector_from_cell(cell_z) - sect_z ' ' Sanity Check, X and Z may be either -1, 0, or 1 If (X < -1 Or X > 1 Or Z < -1 Or Z > 1) Then Exit Sub End If ' Update the Sequence variable for the current sector 'You can use this syntax too sdk.aw_seq_3x3(z + 1, x + 1) = sdk.aw_int(AW_CELL_SEQUENCE) sdk.aw_sequence_set AW_SEQUENCE_3X3, (Z + 1), (X + 1), sdk.aw_int(AW_CELL_SEQUENCE) Else ' Get the current cell cell_x = sdk.aw_int(AW_CELL_X) cell_z = sdk.aw_int(AW_CELL_Z) ' Calculate the sector the cell is in X = sdk.aw_sector_from_cell(cell_x) - sect_x Z = sdk.aw_sector_from_cell(cell_z) - sect_z ' ' Sanity Check, X and Z may be either -2, -1, 0, 1, 2 If (X < -2 Or X > 2 Or Z < -2 Or Z > 2) Then Exit Sub End If ' Update the Sequence variable for the current sector 'You can use this syntax too sdk.aw_seq_5x5(z + 2, x + 2) = sdk.aw_int(AW_CELL_SEQUENCE) sdk.aw_sequence_set AW_SEQUENCE_5X5, (Z + 2), (X + 2), sdk.aw_int(AW_CELL_SEQUENCE) End If End Sub ---------------------------------------------------- Private Sub sdk_EventCellObject() 'Handle Objects here End Sub ---------------------------------------------------- -Baron [View Quote] |