| 01-30-2005, 09:42 PM | #1 |
Okay, for my map you get points accumulated into a variable. The points can be up to 99,999 points. As such ive made 10 units, (small squares with the number 0-9 on them). I wish to make it so that every .05 seconds, the variable with the score is read, and then replaces the numbers to make the number display properly. How might I go about doing this other than making 99,999 if/then/else actions? |
| 01-30-2005, 09:53 PM | #2 | |
Quote:
well i would say use a switch but there isn't any in JASS i thinks... too bad... but to show your variable you can use a board... You don't want ? ^_^ |
| 01-30-2005, 09:57 PM | #3 |
No I dont. My map is supose to be an exact duplicate of the original Pacman game, as such, the score must be white block numbers in the black border, not in a multiboard in the top corner. |
| 01-30-2005, 10:04 PM | #4 |
Gah! I started writing an explanation and accidentally went back and lost it. Let me give you the gist of what I would do. Use the Math - Modulo function to determine what each digit will be. This is available when you are setting the value of an integer value. If their score was 67,901 Then 67901 Mod 10 = 1 (67901 - 67901 Mod 10) Mod 100 = 0 67901 - 67901 Mod 100) Mod 1000 = 9 etc etc. I would place each of your score units into a unit group, where their index of that group is the same as the digit they represent. For example: YourUnitGroup[0] = The Unit that has 0 for it's model etc etc. (again). Does that take you far enough along to finish it? |
| 01-30-2005, 11:27 PM | #5 |
The problem with that is, if the score is 10, then the remainder is 0 when 10/10...So rather than is being displayed as '00010' it will be displayed as '00000' which of course is a problem, sence all numbers possible are divisble by 10 (You gain points by 10's, 300's, 400's, and 500's)...Then what do I do? |
| 01-30-2005, 11:41 PM | #6 |
Hmm, you're right, that method does to have a flaw in it (actually a couple, now that I think about it). Sorry about that, glad you caught it before you did the work. I'll keep thinking (or maybe start thinking). EDIT: Wow, much easier solution would be to convert the integer to a string and then use the Substring function. Will that work for you? |
| 01-30-2005, 11:45 PM | #7 |
I thought perhaps by converting the score into a strong, I could use substrings to read each digit...however then ide end up with 91 instead of 00091 ... which of course would cause problems when looking for a substrin in the position 4,4. EDIT: Heh looks like we're on the same wavelength. Im not quite sure, like I said, the 000 will be a problem.... |
| 01-31-2005, 01:20 AM | #8 |
To get the extra zeroes on there, perform a check on the String length. If the length is < 5, then use the concatenate string function to add the necessary number of zeroes on to it. For Each Integer A from 1 to (5 - Length of (YourString)) YourString = "0" + YourString or something like that. Incidentally, it was kind of funny, I made my last post and went on a walk and went out to eat...came back, and here I am again with more info! |
| 01-31-2005, 05:19 PM | #9 |
Heh, one step ahead of ya :8 . About an hour after I posted I realised what to do and did it just before heading off to bed! Heh, but had I not noticed it, im glad you figured it out too. Thanks for your help with this rather anoying delema. |
| 02-12-2005, 05:05 AM | #10 |
Guest | H0w bout you make the white dots as gold and when you pick them up it adds to your gold soooo when you a certin about of gold ( from picking them all up) then it goes tot he next level or w/e |
| 02-12-2005, 10:33 PM | #11 |
Could you not just do an IF/THEN/ELSE to see if it would be 10/10 or something similar and manually account for that error. |
| 02-12-2005, 10:38 PM | #12 |
@ Hacken_Hacker: Thats pointless, doesnt solve anything. Actually, it complicates things. @ ThyFlame : Not when there is 99999x99999 possibilities, no. Doesnt matter anyway. We solved the problem, as you can see if you read the entire thread. No point bumping a dead thread. |
