I’m using large variables to keep track of a lot of information. I started with 11-digit variables and it worked fine, but now that I just tried a 40 digit variable to record wardrobes and call them with {wardrobe#30}
or somesuch, I’ve run into an error where Randomtest and maybe ChoiceScript itself converts my variable. What was once just a long number, allowing me to call each digit to check if a binary flag was switched, now is converted into a shortened version like “1.0000000001000101e+40”
Naturally, this is a problem. Calling {wardrobe#20}
or so snags the e instead of a 0 or 1, and it shortened the variable so calling {wardrobe#40}
fails. Does anyone know the digit limit before choicescript converts a variable, and if that can be fixed in a patch?
I can and will be coding around it, but felt it should be brought up.
3 Likes
It shouldn’t be a limit for numeric variables. However, that doesn’t mean it’s stored as a binary. What you’re trying to do works well for numbers not that long. If you want to store 40+ bits I would suggest doing so in another way.
For anyone wondering, finally finished checking and the limit is 21 digits before the code starts converting it to something else like 1.0001000001000102e+21
2 Likes
I don’t think there is a length limit for variable, because we never have to declare its length when creating the variable itself
I once created a variable that stores an entire inventory, which around 120 digits ( 4 item ID length x 30 slots )
and it was not a create_array inventory 30, it was create inventory, just a single variable storing 120 digits of item IDs
You should use a string instead of a number.
2 Likes
It’s less a ChoiceScript thing and more a JavaScript thing. That’s a thing that JavaScript does with integers at that size.
There are ways to parse this number if you really want, but it’ll be messy and likely involve *script calling functions written in JS
I may be wrong but I believe cup_half_empty solution will solve your Issue. Just Declare your datatype as string and avert using operations that may cause the intrepeter to think you are dealing with numbers rather than chars.
Or, you can download one of the other user made solutions…
1 Like