PDA

View Full Version : GetCurScreen....returns integer??!



Moresco
12-16-2006, 07:20 AM
So, if it does, what is it returning??? I was hoping I could get the number of the screen I'm currently on, and somehow use that to my advantage whilest coding. Unfortunatley, since I can't test the variable to like, print the current value or anything, I have to guess. The screen is M1 S46 according to ZQuest's menu. Soooo, that can't be right, because 46 is hex, right? On my window, if I scroll right, 46 goes up to 49, and then becomes 4A...until 4F being the final before moving on to 50. Anyway I converted 46 from hex to decimal, and the script still wasn't working (I resorted to playing sounds to see if my statements were working).

So this is the code I worked out, and the only thing the compiler would accept, hope I got it right:

int variableName = 0;
variableName = Game->GetCurScreen();

So then I finally got somewhere searching for whatever value was being stored in the variableName. But, it was above 0 and below 4. But did not == 0, 1, 2, 3, or 4...so what gives? I'm doing this wrong...I must be.

Anyway I'm also having trouble with Game->GetCurMap();

What are these functions doing? I play the game, ask it to run an if statement when the Current Map is == to 1, the map I'm playing on, the overworld and first map I made. but it doesn't run, so I asked it to run if the current map is == to 0, and voila...it ran. So I initialized the variable to 3, just to see if it would run again and claim it was on map 0. It did, so it thinks it's map 0. In the ZQuest, it says it is Map 1.

Back to GetCurScreen....which I still don't understand. I tried putting this in a while loop, using waitframe() and recalling GetCurScreen at the beginning of every iteration of the while loop. It still claims the screen value returned is greater than zero, but not greater than 1. I tried asking it if it was greater than 0.1, and it said no.

So in conclusion, does anyone else understand these? Am I totally wrong? Help me out.

eXodus
12-17-2006, 11:01 PM
First things first, there is a debug method for printing an expression at runtime, but not to the screen. From the stickied Documentation thread:


void Trace(float val)
* Prints a line containing a string representation of val to
* allegro.log. Useful for debugging scripts.
Really useful when the code is working but not the way you expect it to. For example, I once tried to divide a float by a literal integer ( <int variable> = <float variable> / 16; ), and couldn't get a thing out of it. After using trace(), I found it was putting the integer result at the lowest part of a float ( 0.00XX ) before truncating it to 0 every time. Sounds just like what Game->GetCurMap() is doing to you there - returning 0.0001 on Map 1. I don't have that script on hand to remember how I solved it though...

As for Game->GetCurScreen(), it should return the same screen numbers as you see in ZQuest ( to the right of 46 is 47, up is 36, etc. ) except in decimal. Note that I haven't had to use any of the functions requiring a room number yet so I may be wrong there, but it's the only thing I can think of that makes sense to me. Just trace() it to make sure, but my guess is it's doing what I mentioned above anyway.

Moresco
12-17-2006, 11:29 PM
Wow that's awesome! Thank you sooo much for pointing that out to me. Right away it made more sense. The room is 46, which in dec is 70, and it was calling it 0.0070 in the log. This should go in the documentation or something...

Here's a little bit of interesting info. When you use GetCurMap, it will return 0.0000 for Map 1 and 0.0001 for Map 2...and so on.

Dark Nation
12-18-2006, 11:57 AM
That may actually be a bug. I'll check with the other devs on this.