Looping & Debugging

Hi guys,

I have two technical questions:

  1. how do I bypass an error saying that “visited this line too many times” ???

apparently my codes simulates a turn-based combat like suikoden game where two parties fighting and each party has six members at most, so I do understand that there will be lots of looping and reading the same code over and over again

the process itself was fast, but upon reaching certain turns, the error pops out, how can I fix this?

  1. debugging gets harder with more codes and loops, can we implement a new syntax that makes the code enter debugging mode?

like a “breakpoint” on other programming language, it makes debugging faster and focused on certain part of the code, and we can stop clicking “step” one by one because it feels horrible

if many agrees with my suggestion and feel the same problem while debugging, maybe we can push this feature to be implemented?

thank you

Create a variable that tracks how many times you visit the choice and then set up an *if to catch it.

*create check 0

*label menu
*if check > 2
*goto next
*set check +1
*goto menu
*set check +1
*goto menu

*label next

1 Like

I am not sure if you are using RandomTest for debugging, so disregard this part is you are - but if not it is essential especially if you have complicated code as you describe. You can use *if (not(choice_randomtest)) to block RandomTest from picking certain choices if you want to focus on a particular path or section.

You can use *looplimit 0 to switch off the limit on infinite loops but that will cause issues when using RandomTest. I would suggest including an option that forces the combat to end, at least for testing purposes, so when playtesting you don’t have to play through the whole section every time and RandomTest can move past the section.

Here is more about *looplimit:


Step through debugging is supported by CSIDE: [CSIDE] The ChoiceScript IDE (v1.3.3 Now Available — 05/09/2022)


I had to increase looplimit to *looplimit 3000 instead of 1000 in order to get the save system for FH to work, it might be worth trying to just increase it rather than turning it off to see if that gives enough space for the combat to run as intended.


Looping & Debugging - #3 by HannahPS
Looping & Debugging - #5 by malinryden

so, even if I didn’t use the syntax *looplimit to set the limit, the limit is always 1000 iterations by default?

because I don’t have *looplimit in my current code

1 Like

Exactly. The default value is 1000, as that works for most things. However, occasionally it might be too little, and the *looplimit code needs to be added to change it. It will not be there now.


ahem sorry to bug you guys again, where do I put the *looplimit command?

I tried putting it on startup file like this:
it didn’t worked, I changed to *looplimit 0, still didn’t worked, error still popped out

and this is how I do looping in choicescript:
I have no worry about infinite loops because I set the lower and upper limit before do the looping, but this loop limit makes me confused

so, where should I put *looplimit command? or did I loop it the wrong way all this time?
can someone show me the correct looping method and the use of looplimit the way choicescript accepts?

thank you

EDIT: okay I think I found it, I put it here:
I had to set it to 0, because when I set it to 1,000,000,000,000 ( 12 zeros ), the program forcefully exit the subroutine ( the label is a subroutine that gets called over and over again ) midway when reaching 1000 iterations and I don’t know why

I guess it is solved for now, thank you everyone

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.