aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-10-21 16:39:54 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-10-21 16:39:54 +0200
commit74f7233d216da5a37a36fd54be4d8d6a4a278c8b (patch)
treea39a293363c307dad828911bf92788ac572db958 /advtrains_luaautomation
parent7977776b4a8067ea513d95ab2b0d699456596209 (diff)
parent27f85f2e225e038789036fac4407d97aacb2189b (diff)
downloadadvtrains-74f7233d216da5a37a36fd54be4d8d6a4a278c8b.tar.gz
advtrains-74f7233d216da5a37a36fd54be4d8d6a4a278c8b.tar.bz2
advtrains-74f7233d216da5a37a36fd54be4d8d6a4a278c8b.zip
Merge branch 'master' of https://git.bananach.space/advtrains
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/README.txt12
-rw-r--r--advtrains_luaautomation/active_common.lua16
-rw-r--r--advtrains_luaautomation/depends.txt1
3 files changed, 29 insertions, 0 deletions
diff --git a/advtrains_luaautomation/README.txt b/advtrains_luaautomation/README.txt
index a07bbb4..20ef816 100644
--- a/advtrains_luaautomation/README.txt
+++ b/advtrains_luaautomation/README.txt
@@ -114,6 +114,18 @@ aspect = {
}
As of August 2018, only the aspect.main.free field is ever used by the interlocking system.
+# Lines
+
+The advtrains_line_automation component adds a few contraptions that should make creating timeable systems easier.
+Part of its functionality is also available in LuaATC:
+
+- rwt.* - all Railway Time functions are included as documented in https://advtrains.de/wiki/doku.php?id=dev:lines:rwt
+
+- schedule(rw_time, msg)
+- schedule_in(rw_dtime, msg)
+Schedules an event of type {type="schedule", schedule=true, msg=msg} at (resp. after) the specified railway time.
+(which can be in any format). You can only schedule one event this way. (uses the new lines-internal scheduler)
+
## Components and events
The event table is a table of the following format:
diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua
index 5d8cc48..8d0975f 100644
--- a/advtrains_luaautomation/active_common.lua
+++ b/advtrains_luaautomation/active_common.lua
@@ -123,6 +123,15 @@ function ac.run_in_env(pos, evtdata, customfct_p)
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
end
end
+ -- add lines scheduler if enabled
+ if advtrains.lines and advtrains.lines.sched then
+ customfct.schedule = function(rwtime, msg)
+ advtrains.lines.sched.enqueue(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1)
+ end
+ customfct.schedule_in = function(rwtime, msg)
+ advtrains.lines.sched.enqueue_in(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1)
+ end
+ end
local datain=nodetbl.data or {}
local succ, dataout = atlatc.envs[nodetbl.env]:execute_code(datain, nodetbl.code, evtdata, customfct)
@@ -144,4 +153,11 @@ function ac.on_digiline_receive(pos, node, channel, msg)
atlatc.interrupt.add(0, pos, {type="digiline", digiline=true, channel = channel, msg = msg})
end
+if advtrains.lines and advtrains.lines.sched then
+ advtrains.lines.sched.register_callback("atlatc_env", function(data)
+ -- This adds another interrupt to the atlatc queue... there might be a better way
+ atlatc.interrupt.add(0, data.pos, {type="schedule",schedule=true, msg=data.msg})
+ end)
+end
+
atlatc.active=ac
diff --git a/advtrains_luaautomation/depends.txt b/advtrains_luaautomation/depends.txt
index 1b4fd87..d5523e1 100644
--- a/advtrains_luaautomation/depends.txt
+++ b/advtrains_luaautomation/depends.txt
@@ -1,3 +1,4 @@
advtrains
advtrains_interlocking?
+advtrains_line_automation?
mesecons_switch? \ No newline at end of file