djkrose / 7DTD-ScriptingMod

Adds scripting support and other useful functionality to 7 Days To Die dedicated server
19 stars 10 forks source link

Run scripts periodically by configurable timers #7

Open djkrose opened 7 years ago

djkrose commented 7 years ago

It should be possible to run scripts repeatedly based on timers, similar to a cronjob.

ddumont commented 7 years ago

Is setimout or setinterval not available in the js runtime?

djkrose commented 7 years ago

No, because this is part of the window object, which does not exist without browser. I might add these two methods later, but it would still require someone to execute a command initially, after every server restart.

It is also problematic to have long-running scripts, because commands are executed on the main thread and freeze the server while executing. Adding the possibility to delay execution with settimeout is not trivial.