so in my day and night callbacks add-on, i have a system for dynamically determining how long a schedule should wait before running again.
this is to prevent gayass 500ms schedule loops.
You can see the function
here (line 51) and the place where it is used
here (line 51, heh)E: forgot to post problem lol, editing
E: ok lets try this again
the system works by starting a
while() loop and then it, starting from the current simTime, starts incrementing a fake sim time repeatedly until it reaches a fake sim time that calculates out into a different part of day than the current one
then it calculates the difference in MS from the fake sim time to the current sim time, and sets a schedule to wait until then.
key point: the system works... on kalphiters servers. on a weaker, homehosted server, the system may cause crashes, blockland hanging, timeouts, or all of the above. this is because of the goddamned inefficiency of it and because i'm bad at maff.
I need someone to help me optimize the process to meet the following criteria:
- uses less while() iterations
[0]does not result in overshooting, even if it takes 700 iterations of a daycycle to be half a day off - it's not acceptable.