-- init code for LW timetable env -- stop, scheduled departure every -- d_int: Departure every n seconds (epoch modulo) -- d_off: Departure time offset function F.stop_sd(st_name, doors, departcommand, minstoptime, d_int, d_off) if event.train then local timenow = os.time() local timerdy = timenow + minstoptime local wait = d_int - ((timerdy-d_off) % d_int) local waitcorr = math.floor(wait*0.66) digiline_send("monitor", "Departure scheduled for: | "..os.date("%H:%M:%S", timenow+wait)) atc_send("B0 W O"..doors.." D"..waitcorr.." OCD1"..departcommand) else local timenow = os.time() digiline_send("monitor", "Time: "..os.date("%H:%M:%S", timenow)) end end function F.stop_sd_sched(st_name, doors, departcommand, minstoptime, d_int, d_off) depart = false if event.train then local time_now = rwt.now() local next_dep_time = rwt.next_rpt(rwt.add(time_now, minstoptime), d_int, d_off) digiline_send("monitor", "Departure scheduled for: | "..rwt.to_string(next_dep_time, true)) atc_set_text_inside(st_name.."\nDeparture: "..rwt.to_string(next_dep_time, true)) atc_send("B0 W O"..doors) schedule(next_dep_time, "depart") elseif event.schedule then atc_send("OCD1"..departcommand) digiline_send("monitor", "Last Departure: | "..rwt.to_string(rwt.now(), true)) atc_set_text_inside("") depart = true end end function F.timedisplay() digiline_send("time", "Time: | "..rwt.to_string(rwt.now(),true).." | "..os.date("%H:%M:%S")) schedule(rwt.next_rpt(rwt.now(),5,0), "") end