Author Topic: Anything more reliable than schedules for script loops?  (Read 4250 times)

I often make add-ons with code that runs repeatedly on objects - most notably the trains mod. However i've noticed this can:
- be inaccurate
- break when the server is lagging

Is there a better way to have loop code work than this?



Yeah, there's not much else to try.

Break? What do you mean? I use schedules a lot as well and I've never had problems with that.

For critical schedules I use scheduleNoQuota just in case.

If you wanted to keep it from losing accuracy over time, you could keep track of the time the schedule was made through an argument, then compare the current time to the time it was made plus the delay, then offset your schedule based on that.

Is there a function that calls the time since server start? That could also be useful for regulation.

Is there a function that calls the time since server start? That could also be useful for regulation.

getSimTime();
$Sim::Time


best you can really do is put a check inside the loop (at the beginning) and check that the loops run time - the servers uptime = the time you started the loop

if it isnt true, make corrections to the schedule time


While True loop.
I've had bad experiences with while loops in Blockland. ;-;

I've had bad experiences with while loops in Blockland. ;-;

I think he was just being a troll.

I think he was just being a troll.
Funny, when I first read Starzy's post, I thought of you.
while(1){}


User was banned for this post

getSimTime();
$Sim::Time

you shouldn't use $Sim::Time because if the server is up for a long time the numbers will be so large it will cause glitches