Calculating large numbers with variables set as text

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey I need help, so I have a variable called diamonds. Each diamond cost 10^21 gold. In C2 int types have a limit of 10^18. Anything higher needs to be set as text. My players want a buy all diamond QOL change. I tried adding on click if gold > singleDiamond cost then set value of buyMassDiamonds to gold / singleDiamondCost. But the var buyMassDiamonds does not accept the the formula as one is text and one is an int. I played around with it and it works if both are ints (as smaller values), but does not work if both are text. Does anyone know a solution to this?

    Thank you.

  • Can't you just use smaller numbers? E.g. use units of 10^15, and then all your other numbers will fit easily.

    Construct 2 doesn't have an integer type by the way, it's all floats. Are you sure you're using C2 and not something else?

  • No it's an idle game, it needs big numbers. Oops I meant to say number not int, my apologies. Yes its Construct 2. So is there a way around big numbers or was C2 just a poor choice for this genre.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No it's an idle game, it needs big numbers.

    I don't see why this means you can't use smaller numbers.

  • Maybe I'm misunderstanding what you mean. So in the game players gather a lot of gold, gold reaching up to 1^30+ In order for me to have end game upgrades, those upgrades need to be expensive to buy. I can't reduce the price to 1^15, since that number is reached rather quickly. If I reduced the cost, I'd have to re-balance the whole game and with nearly 40k plays on Kongregate that would equate to a lot of angry players.

    I tried looping the buy event, but at that many circuits of the loop the browser freezes. My buddy who purchased Construct 3 said that isn't an issue with C3. So I'm not sure what to do now.

  • If you store everything in units of 10^15, then internally you are dealing with smaller numbers that won't hit the limit. When you display them to the user, you can just add a few zeros on the end so it looks the same. So this shouldn't break anything or make any visible difference to the user, but means the actual stored numbers are much smaller so fit within the precision limits.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)