aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_line_automation/init.lua')
-rw-r--r--advtrains_line_automation/init.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua
new file mode 100644
index 0000000..7b758bc
--- /dev/null
+++ b/advtrains_line_automation/init.lua
@@ -0,0 +1,47 @@
+-- Advtrains line automation system
+
+advtrains.lines = {
+ -- [station code] = {name=..., owner=...}
+ stations = {},
+
+ --[[ [new pos hash] = {
+ stn = <station code>,
+ track = <platform identifier>,
+ doors = <door side L,R,C>
+ wait = <least wait time>
+ reverse = <boolean>
+ signal = <position of signal that is the "exit signal" for this platform>
+ }]]
+ stops = {},
+}
+
+
+local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM
+
+dofile(modpath.."railwaytime.lua")
+dofile(modpath.."scheduler.lua")
+dofile(modpath.."stoprail.lua")
+
+
+function advtrains.lines.load(data)
+ if data then
+ advtrains.lines.stations = data.stations or {}
+ advtrains.lines.stops = data.stops or {}
+ advtrains.lines.rwt.set_time(data.rwt_time)
+ advtrains.lines.sched.load(data.scheduler_queue)
+ end
+end
+
+function advtrains.lines.save()
+ return {
+ stations = advtrains.lines.stations,
+ stops = advtrains.lines.stops,
+ rwt_time = advtrains.lines.rwt.get_time(),
+ scheduler_queue = advtrains.lines.sched.save()
+ }
+end
+
+function advtrains.lines.step(dtime)
+ advtrains.lines.rwt.step(dtime)
+ advtrains.lines.sched.run()
+end