Re: setTimeout and data storage
By: Xeanalyth to DOVE-Net.Synchronet_JavaScript on Thu Jul 19 2012 19:25:04
!JavaScript /home/bbs/mods/stock/main.js line 13: ReferenceError: setTimeout is not defined
setTimeout is not defined? How does one go about executing
timed events?
Careful with that "timed events" term - it has its own meaning in Synchronet (stuff that's been scheduled via SCFG.)
While we don't have the setTimeout function that's present in many browsers, we do have exec/load/event-timer.js, which mcmlxxix wrote to provide a Timer object. More info is available in the comments at the top of event-timer.js, but here's a rough example of how to use it:
load("event-timer.js"); // Loads the library
var t = new Timer(); // Instantiates a timer for your script
// Add an event to your timer:
t.addEvent(30000, true, console.print("LOLDONGS"));
/* As your script loops, you'll need to cycle the timer to have it run any
pending events. */
while(stuff is happening) {
timer.cycle();
}
echicken
electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
---
þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com