[Script] - Smart Spawner

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: [Script] - Smart Spawner

Post 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.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
Ixnatifual

Re: [Script] - Smart Spawner

Post 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.
Post Reply