ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Using coords for teleport (Sdk)
Using coords for teleport // SdkdionJul 2, 2002, 9:00pm
Sorry for all of these. :-P I'm workin on my first bot so I've got tons of
questions. I'm trying to turn something like '0n 0w' that you use to teleport using the activeworlds browser, to integers X and Z that can be used to teleport the bot. This is what I tried and uh.. it's teleporting me to 0n 0w so I did something wrong. Since I get ejected for 5minutes everytime I try something new uh... it's pretty hard to do. LOL, I should start testing my bot in my world :-D I know the code is messy, I'm new with VB and I wasn't exactly trying to make neat code :-P Anyway, give me your tips, advice, and if you can, some working code! "Private Sub TportButt_Click() Dim teleport As String Dim NS As String Dim EW As String Dim intX As Integer Dim intZ As Integer Dim intStart 'turn coords into meters the bot can use to tport teleport = Coords.Text intX = InStr(1, teleport, "N") If intX = 0 Then NS = "S" Else NS = "N" End If intZ = InStr(1, teleport, "E") If intX = 0 Then EW = "W" Else EW = "E" End If For X = 2 To 35 intX = Val(Left(teleport, X)) If Mid(Str(intX), X, 1) = "N" Or Mid(Str(intX), X, 1) = "S" Then Str(intX) = Left(teleport, X - 1) If NS = "S" Then intX = intX * (-1000) If NS = "N" Then intX = intX * 1000 Exit For End If Next X For X = 2 To 35 intX = Val(Left(teleport, X)) If Mid(Str(intZ), X, 1) = " " Then intStart = X If Mid(Str(intZ), X, 1) = "E" Or Mid(Str(intZ), X, 1) = "W" Then Str(intZ) = Mid(teleport, intStart + 1, X - 1) If EW = "E" Then intZ = intZ * (-1000) If EW = "W" Then intZ = intZ * 1000 Exit For End If Next X rc = ChatForm.SDK.AwEnter(World.Text) If rc Then ChatForm.AwChat.SelColor = vbRed ChatForm.AwChat.SelBold = True ChatForm.AwChat.SelItalic = False ChatForm.AwChat.SelText = "Error! Reason " & rc & vbCrLf Exit Sub End If ChatForm.SDK.AwMyX = intX ChatForm.SDK.AwMyY = 0 ChatForm.SDK.AwMyZ = intZ ChatForm.SDK.AwMyYaw = 0 ChatForm.SDK.AwMyType = 0 rc = ChatForm.SDK.AwStateChange If rc Then ChatForm.AwChat.SelColor = vbRed ChatForm.AwChat.SelBold = True ChatForm.AwChat.SelItalic = False ChatForm.AwChat.SelText = "Error! Reason " & rc & vbCrLf Exit Sub End If End Sub" grimbleJul 2, 2002, 9:30pm
Does "Str(intX) = ..." compile ??? I think that's your problem from a quick
glance. Really surprised it compiles though. I wouldn't expect that to do anything to the value of intX. Str converts a numeric into a string, but the store for that string isn't the same as the numeric. So, the value of intX isn't changing and remaining at zero. Same for intZ further down. Just "intX = Left(teleport, X - 1)" would work. Have to say at this point that I didn't run the code ... short on time, sorry. Grims. [View Quote] dionJul 2, 2002, 11:38pm
I don't normally compile until I have finished. I thought the way it was run
through visual basic was how it would run after compiled. [View Quote] grimbleJul 2, 2002, 11:44pm
It should be ... I would have expected that the throw up an error when it
compiles the procedure (when it is about to execute it). Its always a good idea to run it in the IDE using Ctrl-F5 (run with full compile) though ... it mean you'll find all the syntax errors before it runs and not during the execution (which will throw up an error. I didn't mean compile to an exe. Grims [View Quote] grimbleJul 3, 2002, 12:02am
OK, I just tried it out and there's several issues in there. Is it important
to try to parse (and have to validate) a "100N 53E" style location? You would have a much simpler job if you had separate edit boxes for NS and EW cooords. If you really want to progress with this, there are ways to do it, obviously, but I imagine this isn't the most important part of the app when there's an easier alternative available. Grims [View Quote] dionJul 3, 2002, 12:27am
I finally got it anyway. What you mentioned was a problem but not the only
one. There were lots of em :-P And a few piece of unnecessary crap :-P Anyway, for anyone interested, here's the code: Private Sub TportButt_Click() Dim teleport As String Dim intX As Long Dim intZ As Long Dim intStart As Integer 'turn coords into meters the bot can use to tport teleport = Coords.Text For X = 2 To 35 If Mid(teleport, X, 1) = "N" Or Mid(teleport, X, 1) = "S" Then intX = Val(Left(teleport, X - 1)) If Mid(teleport, X, 1) = "N" Then intX = intX * (-1000) If Mid(teleport, X, 1) = "S" Then intX = intX * 1000 Exit For End If Next X For X = 2 To 35 If Mid(teleport, X, 1) = " " Then intStart = X If Mid(teleport, X, 1) = "E" Or Mid(teleport, X, 1) = "W" Then intZ = Val(Mid(teleport, intStart + 1, X - 1)) If Mid(teleport, X, 1) = "E" Then intZ = intZ * (-1000) If Mid(teleport, X, 1) = "W" Then intZ = intZ * 1000 Exit For End If Next X rc = ChatForm.SDK.AwEnter(World.Text) If rc Then ChatForm.AwChat.SelColor = vbRed ChatForm.AwChat.SelBold = True ChatForm.AwChat.SelItalic = False ChatForm.AwChat.SelText = "Error! Reason " & rc & vbCrLf Exit Sub End If ChatForm.SDK.AwMyX = intZ ChatForm.SDK.AwMyY = 0 ChatForm.SDK.AwMyZ = intX ChatForm.SDK.AwMyYaw = 0 ChatForm.SDK.AwMyType = 0 rc = ChatForm.SDK.AwStateChange If rc Then ChatForm.AwChat.SelColor = vbRed ChatForm.AwChat.SelBold = True ChatForm.AwChat.SelItalic = False ChatForm.AwChat.SelText = "Error! Reason " & rc & vbCrLf Exit Sub End If End Sub [View Quote] > cooords. If you really want to progress with this, there are ways to do it, > obviously, but I imagine this isn't the most important part of the app when > there's an easier alternative available. > > Grims > > > [View Quote] |