Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

[Sugarcube] Using one number to store multiple variables.

$
0
0
Hy, I'm not quite sure how to put this.

I'd like to use one number(for example 1000) to store multiple variables by variables by modifying and reading individuals digits. For example if the character does one action the number changes to 1001, while another changes it to 1010. Then by reading the 3rd and 4th digits I can tell what action was done.

I'd like to do this to avoid variable explosion by keeping a lot of thematic related information in one space. I can make do currently making extensive use of divide by 10 and modulus by 10, but considering Sugarcube already has a "split" function, I was wondering if it would also have a "get character at position x" function.

The one way I though to do this without a special function is creating special "math" passages, where I use a hidden <<display>>function inside a passage to call up the formula needed to access a specific digit in a variable. Is this the only way?

Thanks for any help. :)

edit:typo fixing

Viewing all articles
Browse latest Browse all 1844

Trending Articles