I’m running Quicktest on my project and it’s failing, even though Randomtest and playing through both work fine.
The error I’m getting is: “Error: wilderness line 1504: Non-existent variable ‘gr_3_10’”
My code (which I will admit is a bit baroque for ChoiceScript, but it does work beautifully) is designed to describe a particular location on a grid. We enter the “wilderness” scene with *goto_scene wilderness leave_city
. Since the city’s coordinates on the grid are 3 x 10, we set the grid_x
and grid_y
variables to 3 and 10 respectively. We then go to the build_map
subroutine, and then proceed to navigation
.
*label leave_city
*temp grid_x 3
*temp grid_y 10
*gosub build_map
*goto navigation
build_map
is a long list of *temp
variables. The relevant one is gr_3_10
.
*temp gr_3_10 "[City Name]"
navigation
uses some charming variable hacks to figure out what’s on tile 3 x 10. The second of these lines is 1504, where the Quicktest fails.
*temp ref_this "gr_${grid_x}_${grid_y}"
*temp tile_this {ref_this}
In other words, the first line sets the variable ref_this
to the string “gr_3_10”. The second line sets the variable tile_this to the value of the variable gr_3_10
, which should be “[City Name]”. There’s a reason this technique is described in the “truly bizarre references” section of CoG’s Advanced Choicescript page - but I swear it does the job perfectly in playthrough. However, Quicktest thinks that gr_3_10
doesn’t exist, even though it’s set in the build_map
subroutine which runs before navigation
.
Is it possible that Quicktest isn’t waiting for the build_map
subroutine to finish before moving on to navigation
? Or does it have a problem with the curly braces syntax? I know that QT will skip any *goto_scene
or *gosub_scene
that uses curly braces like this, but build_map
is a regular old *gosub
. I’d hate to lose the power of QT entirely on this work because of this. I suppose, in a pinch, I could intentionally exploit the fact that QT won’t *goto_scene
with curly braces and keep it out of the wilderness scene altogether, but that seems like… not a great solution.
(I swear most of my code isn’t nearly as weird as this example makes it look. It’s only one very particular little subsection that does things like this.)