It’s possible to write an “infinite loop” bug in ChoiceScript, where the game keeps running the same lines of code over and over again, forever. These bugs can be hard to find and fix.
In the latest version of ChoiceScript up on Github, there’s a new error message you can get when your game goes into an infinite loop during Randomtest.
RANDOMTEST FAILED: Error: startup line 34: visited this line too many times
This error occurs when a line has been run (“visited”) 1,000 times in a single Randomtest playthrough, which is a strong indication that your game has an infinite loop. Without this, Randomtest would just run forever if you hit an infinite loop.
I thought it might be possible that somehow you’d actually want to run a line 1,000 times in a single playthrough, so there’s a command to support that, *looplimit
, which you can use like this:
*looplimit 1000000000
*looplimit
lets you raise or lower the limit to any number you like. EDIT: You can can also turn off the looplimit with *looplimit 0
, but I don’t recommend it. Running a line a billion times should be good enough for anybody. (The maximum possible looplimit is approximately one trillion (12 zeroes), but, seriously?!)
In addition, the latest version of ChoiceScript fixes a bug where text wouldn’t appear in randomtest-output.txt
if the game ran forever in an infinite loop.
If you’re having trouble debugging an infinite loop in Randomtest, try running Randomtest with the “full text” option enabled. That will let you see exactly what’s happening during the loop.
Enjoy!