GM_Kill_All_Monsters()
set category = "GM"
var/mon = input("What type?","Kill Monster")as null|anything in monsters
if(!mon)return
world<<'hit.wav'
for(mon in world)
if(!mon)break
if(mon == src)continue
flick("hit",mon)
usr<<"<font color=red>[mon] has been defeated by [src]</font>"
del mon
var/T
for(T in typesof(/monster)-list(/monster,/monster/Boss))
monsters += new T
Problem description:
This turns into an infinite loop, what am I doing wrong?
The problem is, you start out by treating mon as the type of monster to eliminate. Well and good. But then you use that same var as the loop var in for(). So as soon as it enters the for() loop, whatever was in mon before is wiped out, and instead mon becomes the current item in the loop. It's equivalent to this:
Clearly, a is no longer 2 the moment the loop begins.
What you appear to want to do is loop by type path. There's no way to do that without a predefined type, so you'll have to use istype() or such to check. Therefore:
That's basically what you needed to do.
Lummox JR