Anything other than integer has to be transformed to compare.
That goes for .b as well as for .q and last but not least for strings ofcourse.
Comparing string s goes as follows.If "abc" = "abx"
If Asc("a") = Asc("a")
If Asc("b") = Asc("b")
If Asc("c") = Asc("x")
result = 1 ;True
result = 0
;False <<- This is where we break (jump out of the block)
;After 3 Char-to-Int transformations and 3 Int comparisons.
result = 0 ;False
result = 0 ;False
You don't need to do everything every time the mainloop loops.
what_to_do + 1
Case 4 To 99
Delay(5) ;We can allow for plenty of idle-time.
;All of the above functions will still be called several times per second
what_to_do = 0
About my last code:
Each room has an UID. That UID is simply stored as string and integer at once.
Storing the string isn't even necessary, but I did so anyway. It could be useful in the future and doesn't slow the process down much.
So you can access the room by its string-key. Whatever format that is.
At the same time PB only needs to compare the integer when iterating through the list.
So now it's gonna be more complicated if you want to access the room by its XYZ coords.
You must be able to calculate the Integer ID from the string and the other way round.
If you would store the room name as key. You would need a lookup list that is as big as the room list. -> Takes at least two times the time.
So you need to give each one of the directions another part in the number.
Just like RGB.
Debug $FF0000 ;Blue
Debug $0000FF ;Red
Red is the lowest, than green than blue.
The integer is created as follows: Dec(RedPart) + Dec(GreenPart)*255 + Dec(BluePart)*255*255
If you were to simply add the values, the colors wouldn't be unique anymore: 255+0+0 = 255 and 0+0+255 = 255, too.
So you can use Hex or whatever (you could use for example a system based on 36 (26 letters + 10 numbers) which would enable you to create 1296 (36*36) rooms in each direction (actually that's 647 in each direction and up and down, if 0,0,0 is the middle rather than the corner of the cube).
Your ID would be: ZZ00AA for example. X:1296, Y:0, Z:100
Or you could use XXXYYYZZZ in Hex. Then your cube would be 4096*4096*4096 ~68billions of unique rooms if you fill the cube totally.
Ofcourse you are free to choose any limiter you want. XXX;YYY;ZZZ or XXX-YYY-ZZZ etc...
I'll follow with a short example of a cube of rooms where you can identify each one by its coordinates.