Been pondering over a problem I've had since using Gm8, specifically, I was working on an RPG with full mod capabilities, but was struggling with the in game scripting system and how to determine how many lines of code to execute each step to avoid lag. Recently, I've been wanting to start up a new RPG project, but with some procedural generation involved and decided to implement a chunking system for loading the map. Again, I ran into the same problem of figuring out how many subchunks to handle per step without lag. The answer finally hit me while I was at work. Instead of trying to figure out how many cycles to run, I should measure the cycles using time, thus was born a system I named "Tasker", which is just a queue of tasks that need to be performed, and it tries to execute as many as it can per step. It works by taking the ideal framerate, and starts measuring at the begin step event. Tasker runs in the end step event and executes tasks until the measured time that started at begin step exceeds the given threshold (eg: 0.5 = half a step). it then waits until the next step to continue. After solving a silly mistake on my part, it worked perfectly. I even implemented some untested code to handle scaling performance in lagging situations so that Tasker doesn't cause any further lag. I still need to run it through some real life testament but I'm excited to have cracked this issue. as a bonus, Tasker forces me to think differently on how to break up certain aspects of my games to run most efficiently using this system. for example, I can't just dump a task like "create this entire map" into it, as the task would most certainly go over the time limit. I have to instead break it down further to a room by room basis, and even further to a tile by tile.
Edit: Gave a test run of the code that scales performance in low fps situations. Didn't really help, so I changed to code to work so it at least performs one task before passing on to the next step.