Score over a million...
gamesfua
Member Posts: 723
Hey all,
this has actually been tackled before (I'll provide the link below), but the question has to do with GS numbers. If you go over 999,999, the number will turn into a scientific number, instead of displaying, 1,000,000 etc.
My question is in two parts. For starters, I'm curious if anyone has any unique solutions to this, that may not have been presented before? And/or two, if you look at the linked gs forum solution below, you'll see a demo provided with a solution. But I don't fully understand how that solution works. I'm curious if anyone can explain the logic of how that solution works, so that I'm not merely copying the solution- I'm understanding it. Any help would be appreciated.
Thanks as always!
LINK:
http://forums.gamesalad.com/discussion/43171/display-large-integer
this has actually been tackled before (I'll provide the link below), but the question has to do with GS numbers. If you go over 999,999, the number will turn into a scientific number, instead of displaying, 1,000,000 etc.
My question is in two parts. For starters, I'm curious if anyone has any unique solutions to this, that may not have been presented before? And/or two, if you look at the linked gs forum solution below, you'll see a demo provided with a solution. But I don't fully understand how that solution works. I'm curious if anyone can explain the logic of how that solution works, so that I'm not merely copying the solution- I'm understanding it. Any help would be appreciated.
Thanks as always!
LINK:
http://forums.gamesalad.com/discussion/43171/display-large-integer
Best Answers
-
RThurman Posts: 2,881You might want to try the padInt(x,y) function. It will give you a little more wiggle room (maybe to about 100 million).
padInt(game.DisplayNumber,10) -
gyroscope I am here.Posts: 6,598
Hi @anatomyofdreams , I'm sure @RThurman won't mind me explaining...
The padInt expression literally pads out the number in the following way: if there are less places in the number than the amount given (in the "y" of the expression) then zeros are added before the number.
Example: say your integer start value is 21, and you put in a text display behaviour padInt(game.DisplayNumber,2) it will display 21. If you made it padInt(game.DisplayNumber,3) it will display 021, and so on. So for numbers up to 9,999,999, you'd put padInt(game.DisplayNumber,7), and with this example attribute value, it'll show as 0000021.
The example RT gave - padInt(game.DisplayNumber,10), you'd get 0000000021. hope that's made it a bit clearer for you.""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
Really fantastic. Life savers!
Thanks!
..5+
..7
--
..2
Whoops! We need to "carry the one." That demo just carries the one into a different integer attribute when the number reaches 999,999 and resets the number to 0 again.
The trick of the DisplayText actor is that it concatenates the counter number (e.g. 1=1 million) with the <1 million number.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
In my game the currency I would like to hit approx 99,999,999 as the cap. It would seem I can use the padInt correct? Well how would I go about using it in the image font numbers done just like in Tshirtbooths video.
Constrain attribute
self.image = floor((game.money%self.div)/(self.div/10)..".png"
I tried doing this going up to 99 mill like this but it started displaying some numbers odd so I'm thinking it needs to be done with pad int. So would I simply put in padInt(game.money,10) where the game.money is?
I also have an actor that governs when it exceeds the 99,999,999 that it takes the extra out and puts it in another actor to pull from when it goes below 99,999,999. Should I be putting a padInt in there as well? It looks like this:
Rule
game.money>99,999,999 (no the , isn't there in code)
Then
game.excess money to game.excess money+(game.money-99,999,999)
game.money to 99,999,999
Rule
game.money<99,999,999 AND game.excess>0
Then
self.Money transfer to 99,999,999-game.money
game.Money to game.Money+self.Money transfer
game.excess money to game.excess money - self.money transfer
I doubt these two rules would need the padInt, but it doesn't hurt to ask. But as far as the Number Images would it need padInt?
Thanks
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Btw just curious @gyroscope, do you have any idea what "nan" is? Some how my number once went from displaying text of the number to suddenly displaying "nan". If not no big. Well unless i start encountering it frequently lol.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
game.score.."000"