[Resolved] Error message: "prevOption is undefined"


#1

I’m playtesting a game with two scenes (i.e. two .txt files) so far and they pass quicktest without any problems. When I get to the second scene (code below), I get the error message “prevOption is undefined” and the choices aren’t displayed. I see someone else has asked this but it was never resolved, and I can’t find it on the wikia.

EDIT: Resolved! Please see below for possible fix.

Does anyone have any idea why this error message might pop up? Any other details I should include?


`*label consult
You start seeing patients yo

Because you are sadly without receptionist, you ask people to wait in the waiting room, then do all the registration stuff inside.

*choice
  *if (rcount = 1) #It's a bit quiet around here
    *set rcount +3
    *set workday_counter -30
    *goto consult
  *if (rcount = 3) #Call the well-dressed lady in
    *set rcount -2
    *set workday_counter -20
    *goto consult
  *if (rcount = 5) #Call the schoolboy in
    *rand rcount 4 20
    *set workday_counter -20
    *goto consult 
    `

#2

I routinely receive this message in RandomTest. It seems to be an issue with the test script. For example, I will run 100 iterations and receive that error at seed 42. If I then run 100 iterations starting at seed 40, it does not give an error at seed 42 but may give it at seed 91.

I don’t know what PrevOption does, but my guess is that it tracks the previous choices but lost it in the last iteration.


#3

That makes sense! The error shows up in Randomtest as a failure for me too (with 2 iterations), but the thing is, it shows up in normal playtesting (i.e. when playing the index.html file) as well! Hm.


#4

I appear to have fixed it!

The conditions for the choices are such that you see only one choice depending on what rcount is. However, in the code I showed in the first post, the range of values for which options were displayed was not continuous, so it was possible to have rcount be changed such that you couldn’t select any options.


#5

I am having a similar error, but perhaps caused by something else. After each instance of a Random Test, the message “prevOption is undefined” shows at the bottom, regardless of what I change.

Thing is: The game runs completely once, until the end. Then he starts running from a very specific point and soon after stops with the “prevOption” error. Every shingle time.

I’m still experimenting with the possibilities, but I can say for sure is that it doesn’t matter which seed I pick or how many Iterations I choose , the result is always the same: The game runs once until the end, starts from a specific point and ends in another specific point.

:sob:


#6

I took off the resolved tag so that code wizards may try to help your new issue just posted.


#7

Thank you so much, but I was just editing my post to tell that I found the problem. :heart_eyes:

It was just a stupid thing I did; I put my ending scene as one of the very first ones in the *scenes_list at startup, so the random test kept thinking it should go there after running a playthrough. It seems that was the error and now that I put it back to the bottom it works like a charm.(Well, at least that! I still have some other stuff that isn’t going as it should, but I’m going around old posts for that)


#8

Fixed title again. Glad you found your own solution.