HTML Code:
function onCreated()
{
for (temp.npc: findAreaNPCs(0, 0, 64, 64))
{
if (temp.npc.isInClass("testobject"))
{
temp.npc.destroy();
}
}
for (temp.i = 0; temp.i < 100; temp.i++)
{
putNPC2(32, 32, "join testobject");
}
this.loops = 0;
for (temp.i = 0; temp.i < 100; temp.i++)
{
this.loops++;
temp.npcs = findAreaNPCs(0, 0, 64, 64);
for (temp.npc: temp.npcs)
{
this.loops++;
}
}
}
This code generates a loop limit exceeded error. Yes, I know why - this.loops ends up over 10000.
Can it be changed so that a loop counter of "for (object: objectlist)" loop has less impact on the limit? Or it only starts counting if the list is modified inside the loop?
I'm trying to do something similar to the code above (related to checking for NPCs nearby, etc) but it dies out due to the loop limit.