ID:263464
 
Code:
proc
Auto()
while(game==1)
var/auto=rand(1,10)
if(auto==1)
spawn(1)
ReleaseArrow1()
if(auto==2)
spawn(1)
ReleaseArrow2()
if(auto==3)
spawn(1)
ReleaseArrow3()
if(auto==4)
spawn(1)
ReleaseArrow4()
if(auto==5)
spawn(1)
ReleaseArrow5()
if(auto==6)
spawn(1)
ReleaseArrow6()
if(auto==7)
spawn(1)
ReleaseArrow7()
if(auto==8)
spawn(1)
ReleaseArrow8()
if(auto==9)
spawn(1)
ReleaseArrow9()
if(auto==10)
spawn(1)
ReleaseArrow10()
if(playercount<=0)
break

proc
playercheck()
playercount=0
for(var/mob/M as mob in world)
if(M.shot!=1)
playercount+=1
if(playercount<=0)
world << "No more players! Rebooting..."
sleep(100)
world.Reboot()


Problem description:
When Auto() is called, it will freeze and crash Dream Seeker.
Have you tried using sleep()? It looks like you want this loop to keep on going pretty fast-paced, so I guess you could use sleep() with no parameters. This can cause a bit of lag, though. I suggest you find a better way to do whatever it is you're doing.

Also, those spawn(1) statements aren't doing anything. One usually indents after spawn() statements to obtain a wanted effect. Also, maybe you should consider giving those "ReleaseArrow" procedures to the object that releases them. If not, you can make an argument for ReleaseArrow(), num. Also, look up Boolean Variables. I know there is a very good programming article on BYONDscape, and one that touches boolean variables is called Green Programming, I believe, by Lummox Jr.

proc/ReleaseArrow(var/numb)
if(!numb) return
...

proc/Auto()
while(game)
ReleaseArrow(rand(1,10))
if(playercount<=0) break
sleep(10)


You also might want to consider moving the playercount check upwards. I think that would be better, but you probably have a reason for leaving it down there.
In response to CaptFalcon33035
It still crashes...
In response to Eternal_Dread
Start placing some diagnosis messages everywhere, and see where it stops. Maybe it's not Auto, but ReleaseArrow.
In response to CaptFalcon33035
That would be a negative. I ran these previously through verbs, and they worked fine.

Also, it crashes as soon as Auto() is run, thusly, none of the procs are run because of the eternal loop detection in BYOND.

BTW, to prevent confusion, I am calling procs, not verbs.
In response to Eternal_Dread
It might be the while loop, try putting a sleep(-1) at the end of the loop. If it still crashes it's probably something else.
In response to Eternal_Dread
Those are really the only tips and advice I can give you for that snippet. If you followed the directions correctly, it should have worked. If you did follow directions correctly and it did not work, it is something else in your programming.
Several things to note here:
  • spawn statements require the spawned code to be indented. In other words, the code that you want to spawn "belongs" to the spawn statement, and should be indented "under" it. All of your calls to ReleaseArrowN() arn't being spawned, they're happening immediatly.
  • If you have a large list of if statements operating on the same condition (the value of "auto" in this case), it's better to use one switch statement.
  • In this case, however, I'd use the call proc, because all the names are the same:
    var/auto = rand(1, 10)
    var/arrow_proc = "ReleaseArrow[auto]"
    spawn(1)
    call(arrow_proc)()
  • You should never have to use an infinit loop. If you want something to continue forever, be kind to your program and use a recursive function:
    proc/Auto()
    .=..()
    if(playercount > 0)
    spawn() // Recursive procs must be spawned off
    Auto() // or they'll cause the stack to overflow.
  • Unlike sleep, a proc will not wait for the commands under a spawn to execute before returning, which means that this loop you have will loop forever before any of those spawned commands are ever executed, unless by some miracle the variable "playercount" falls to zero or below. I'm guessing you want there to be a wait in between each round of the loop, so what I'd really suggest is this:
    proc/Auto()
    var/auto = rand(1, 10)
    var/arrow_proc = "ReleaseArrow[auto]"
    call(arrow_proc)()
    spawn(1)
    if(playercount > 0)
    Auto()

That's just a guess at how I think your program should work. Because I can't see exactly where Auto() or playercheck() are being called, where playercount is defined, or even what the ReleaseArrowN() functions are supposed to do, I have know way of knowing how your system should work.
In response to IainPeregrine
You should never have to use an infinit loop. If you want something to continue forever, be kind to your program and use a recursive function:

Why not? There's nothing wrong with an infinite loop, assuming that it delays between iterations.
Of course it's crashing, it's an infinite, undelayed loop. It'll keep whirling around as fast as it possibly can forever.

You need a sleep() at the bottom (or top) of that while().