Page 2 of 2
Re: [Script] - Smart Spawner
Posted: Thu Dec 13, 2012 11:17 pm
by HaunterV
Ixnatifual wrote:Ixnatifual wrote: Stuff#
This part
Code: Select all
for e in allEntities(level) do
for _, t in ipairs(spawnedEntityNames) do
if (e.name == t) then
count = count + 1
end
end
end
seems kind of heavy duty, though. Even on a super simple level it looped the second for 117 times. I tried on one of the larger levels and it was a whopping 1968! If only there was an allMonsters function instead of allEntities.
I honestly cant wait until reading a post like that doesn't take me 5 tries to understand.
Re: [Script] - Smart Spawner
Posted: Fri Dec 14, 2012 7:49 am
by Ixnatifual
Xanathar wrote:Even on a super simple level it looped the second for 117 times. I tried on one of the larger levels and it was a whopping 1968! If only there was an allMonsters function instead of allEntities.
Another solution could be to keep the count at the spawn and in the onDie hooks, but then one must be aware of monsters falling in pits which could alter the count (so maybe also keep count in onMove). If there is a real performance problem it might be worth rewriting it with jkos hooks this way.
On the positive side, to test the impact of the script I put a timer that runs the script every .1 seconds on the 1968 level and at least on my machine it gave no noticable performance issues despite the high loop number.