ID:2370158
 
(See the best response by Nadrew.)
Code:
world/loop_checks=0
mob/verb/Serum2()
set category = "Kate"
var/Treats= 0
var/Cycles= 0
var/Start= input("Choose Base IV") as num
Begin
while(Start < 31)
var/IV=roll(1,20)
if(IV <= 3)
++Cycles
--Start
sleep(1)
goto Begin
if(IV >=4 && IV <= 13)
++Cycles
++Treats
world<< "Cycles: [Cycles]/ Treatments: [Treats]"
if(IV >=14)
if(Start==31)
++Cycles
++Treats
world<< "Cycles: [Cycles]/ Treatments: [Treats]"
else
++Cycles
++Start
sleep(1)
goto Begin


Problem description:
It continues to crash dream seeker despite my manual average of, at most, 90 rolls. Does anyone have tips for stopping it from crashing?
Even tried with a start number of 30
Best response
You have a while() below your goto, you're effectively stacking that until the thing crashes.

1) Don't use goto.

2) Your while() has nothing inside of it.

3) Don't use goto.

You can accomplish this entire thing with a few nested loops, I recommend reading up on while() in the reference since you're misusing it badly.
In response to Nadrew
Nadrew wrote:
You have a while() below your goto, you're effectively stacking that until the thing crashes.

1) Don't use goto.

2) Your while() has nothing inside of it.

3) Don't use goto.

You can accomplish this entire thing with a few nested loops, I recommend reading up on while() in the reference since you're misusing it badly.

1) How else do I get it to return to the roller and do a check?
2) It has While( IV < 31) so unless IV is 31 it'll keep rolling


Edit: I found my problem.....While() was running without a block. I indented everything and now its seamless
In DM just about anything you can do with goto is going to be better off with a while() or a similar loop, it makes your code flow a lot smoother and remain readable instead of becoming a giant mess of spaghetti code.

From the looks of it (your code is already a mess), you're wanting to keep the treatment going as long as certain conditions remain unmet, your code doesn't really make it overly clear which conditions terminate the treatment (again, this is why goto is bad), so I'll just assume it has something to do with the 'Cycles' variable, which you're not actually using anywhere but keeping track of how long we've been running.
while(Cycles <= 10)
while(Start < 31)
// Stuff here.
Start++
Cycles++


As an example of course, since your code is already a horrible mess of goto, it's hard to really follow what you're trying to do with it or where the loops are meant to stop.