Howdy, Stranger!


Math help with possible Array solution

CapitalGamesCapitalGames Posts: 5Member
edited November -1 in Working with GS (Mac)
Hi all, I am trying to hack together an array that can be accessible from scene to scene. I saw another post about creating an array that used an actor to store it, but that won't be kept from 1 scene to another. My idea for a simple array is to just use an Index attribute and store each number (0-9 max) in a different digit place. So if I wanted to store the numbers:

1, 7, 3, 2

I would make the index attribute = (1x1000)+(7x100)+(3x10)+2

So I would now have 1732 as the value of the attribute. The problem is how to get the numbers out, that's where my math skills fall short :(

Say I want to get the 3rd place number, what calculation would get me that value?



  • FetaboyFetaboy Posts: 191Member, PRO
    Found this:
    "the key to extracting digits is using integer and modular division. You could directly access the 9 in 1981 with (1981 / 100) % 10. The reason this works is that 1981/100 = 19, and 19 % 10 = 9."
This discussion has been closed.