Quicktest error for variable by reference

I’m having trouble with the quicktest function reporting an error whenever I use variable by reference. The code works when playing, but not for the quicktest. For example:

*create eastwindritualtarget ""

*set eastwindritualtarget "alchemy"

*if (eastwindritualtarget = "alchemy")
*set {eastwindritualtarget} - 1

Successfully works to reduce alchemy by 1, but when I run a quicktest it seems to ignore the “if” command and gives me this error:

Error: choicescript_stats line 2491: Non-existent variable ''

Where line 2491 is “*set {eastwindritualtarget} - 1”

At first I thought "oh, duh, I must have used ’ instead of " somewhere. But I’ve looked through and that’s not it. For some reason it’s setting the variable to use two ’ symbols instead of two " symbols to empty it when I’m not doing that anywhere, and also trying to test the command even when eastwindritual doesn’t = “alchemy”. At first I just removed these sections to quicktest but to add a feature they’re getting more plentiful.

For context as well, this happens in the quicktest to every stat change I do by referencing a variable.

I know this is not the solution/answer, but I’ve also ran into a similar problem with the old(?) referencing notation, *setref, just the error message is different:

Quicktest failed: Cannot read properties of undefined (reading 'length')

Sharing this in case it is helpful for getting closer to the cause.

Hmmmm. I have a thought - just to debug, try to use an actual variable name in the *create instead of “” and see what happens?

Huh, oddly that does fix it. Can’t use it to fix one instance but I can use it to fix the instance that I had to replicate everywhere, so it looks like I can reliably test again. Thanks!

Okay. The cause is Quicktest being Quicktest and ignoring that the variable is always set at that point of the game then.

You could always create a variable that serves no other purpose than to be used in place of the “”.

Quicktest, unlike randomtest, doesn’t actually “play” your game. It therefore has no way of knowing what value that variable is set to at that point in the game.

You can either ensure there’s a suitable dummy default value given, as mentioned above. Or, you can use the special variable: choice_quicktest, in an if condition to appropriately set (or avoid running the problematic code).

It’s for randomtest instead of quicktest, but you can see an example of such a conditional here: cslib/examples/char_creator/character_creator.txt at 45af9d6c221fbe85f4a857ade2d6974c127b62e4 · ChoicescriptIDE/cslib · GitHub