Page 1 of 1
To Minmay- CPU Performance
Posted: Tue Mar 24, 2015 7:05 am
by Eleven Warrior
Hi minmay or anyone else.
I have this idea that if a player does not have to return to a level I destroy all the lights, torchs, fog particles, sky(s), animated trees etc...of that or those levels. Would this overall reduce the CPU usage since it does not need to compute those objects anymore??
If it's so then what sort of code would I need to do this eg: Say I want to destroy all Torchs or lights without doing this:
light_1:destroy()
light_2:destroy() etc...
torch_1:destroy()
torch_2:destroy() etc...
**With torches the holder and torch**
I think there is away to destroy multipule objects in a few lines of code yeah? Anyway thxs for replies

Re: To Minmay- CPU Performance
Posted: Tue Mar 24, 2015 7:35 am
by minmay
I'm not sure how I'm relevant to this in any way. Yes, it would reduce CPU usage since the level would no longer have to be updated. However, if off-level updates are using meaningful resources then something is extremely, extremely wrong with your mod.
The simple way to destroy all objects on a level is
Code: Select all
for i in Dungeon.getMap(levelNumber):allEntities() do i:destroy() end
but you'd want to make absolutely sure that nothing is ever going to use any object on that level ever again. It would be a lot safer and faster to fix whatever insane thing you're doing that's making off-level updates use significant CPU time. Also there's always a risk that the object can't destroy properly and will crash, or that you'll accidentally activate an unfound secret, or...
The only case I can think of where I'd do this is if I'm making some kind of "infinite dungeon" where levels are randomly generated, in which case I would need to reuse levels, and destroy all objects on a level before replacing them with a new generated level. Otherwise this optimization is too small and too dangerous to be worth it IMO, and I do some pretty small and dangerous optimizations. I guess it would reduce save/load times significantly as the game goes on, but I'd rather be able to return to earlier levels instead.
Re: To Minmay- CPU Performance
Posted: Tue Mar 24, 2015 8:05 am
by Eleven Warrior
Hi minmay. Yeah its just basic Objects that I want to destroy like lights, fogs, particle that's all. I don't have any problems with my Mod performance but was just asking if it would improve the game. All timers are stopped or destroyed after use. When the player finishes a level complete they wont have to come back to that level so I just wanted to free up CPU time by destroying certain objects that don't need to be redrawn yeah is this ok man?
I only mean outdoor levels only because they wont need to come back to that level, so if fogs and sky are deleted then the CPU can do other things.
1 - Yes nothing would be used on the level again. eg: trees fogs lights sky.
2 - Nothing on the level would be connected to any other level eg: levers timers counters etc...
I did it in log 1 with only certain objects and tested it all different ways and I worked. Anyhow just wanted to know if you thought is was ok or not at least I know what dangers lie ahead thxs for reply.

Re: To Minmay- CPU Performance
Posted: Tue Mar 24, 2015 11:26 am
by petri
Objects on other levels typically have very little impact on the frame rate. However, save game loading and saving speeds are directly proportional to the number of objects in the game world.
Re: To Minmay- CPU Performance
Posted: Tue Mar 24, 2015 3:17 pm
by Isaac
The ORRR2 used a script that dynamically erased and replaced most of the objects on the map ~even on the current level that the player was exploring; if it was certain that they could not see those locations. The only way this worked was to allow for exceptions to be skipped; objects that had interactions with scripts and anything that caused a problem if erased.
But this allowed for an extremely dense map.
*I should mention that I had no part in making that script.
I think it was already in the project by the time I signed on.
(And at the time, I wouldn't have been able to read it, much less work on it.)
**But it's there to look at.
Re: To Minmay- CPU Performance
Posted: Wed Mar 25, 2015 7:11 am
by Eleven Warrior
Thxs Petri and Issac awesome

My mind is rested.