If I run the game, everything is fine and dandy, but if I run Quickest, I get the following error:
Error: choicescript_stats line 137: Non-existent variable 'arrclass_0'
This is technically true, arr_class_0 does not exist. But the game should not execute that code in the first place anyway because it’s behind the if statement.
A goofy fix would be to add this in the startup file *create arrClass_0 "Bug fix"
But it would be kind of hackish since when I will switch to the *create_array command, it will start the array from index 1 instead of 0.
But I’m interested if there is a way to fix this behavior.
Yeah, I’ve had a problem of this sort before. If you want to fix it without creating arrclass0, then you would have to find a way not to mention or imply the variable in your code. Personally I’ll just create the variable as a sort of bug check.
PS: It seems you’ve not shown us the complete code?
The code shown is the only code that’s relevant to the issue. Quicktest fails as soon as the game starts, it does not get to make any other choices, it just crashes because it tries to reference arrClass_0 even though it should not because the *if(class != 0) would not pass.
This problem does not happen if I run the game. The section just does not appear in the stats screen, as intended.
I was thinking it has something to do with the elseif/else statements. However, if the bug only comes with quickest, you could try ignoring it. Quickest seems to think that if class can be “not zero”, arrclass can also be “not zero”. This implies that class can be zero and arrclass can also be zero (I hope that made sense).
I believe that’s how quicktest is, it doesn’t realize the value can’t be zero because it at the same time tests both the cases where the if clause is true, and where it is not (it doesn’t care if both options actually can happen). (Although why it expects there to be index zero, if arrays start at index one, is beyond me. Unless I misunderstood and they by default do start at zero.)
maybe he sees the class variable as a string during the test, but still compare it to a numeric value in the logical gate “IF”.
So, this way you get a “0” value that is a character rather than a number, hence the:
As @LiliArch has implied, QuicktTest doesn’t actually “run” your game. It scans the code for inconsistencies, so will check both branches of every if. It has no way of knowing what values would be possible at runtime, so it uses your startup value iirc. So you’ll probably have to modify that, or their might be an “*if choice_quicktest”, I know there’s definitely an “*if choice_randomtest”.
In other languages the code compiler always execute a semantic analysis to know if all the variables used are properly declared. So the error is that quicktest is checking up if arrClass_0 is properly declared. In this case you can fix that by literally declare a temp variable:
*temp arrclass_0 ""
edit: Hmm. can we declare temp variables in choicescript_stats.txt? I never tried that…