summaryrefslogtreecommitdiff
path: root/durt/nodes/(-2227,8,292).lua
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-04-22 14:51:45 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-04-22 14:51:45 +0200
commit0b14726c5539782a60d2f4beaed2cfca74a50f7a (patch)
tree1de6e16c565f7bb9806552fc587d7eac870b6b00 /durt/nodes/(-2227,8,292).lua
downloadluaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.tar.gz
luaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.tar.bz2
luaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.zip
State at 2019-12-13
Diffstat (limited to 'durt/nodes/(-2227,8,292).lua')
-rw-r--r--durt/nodes/(-2227,8,292).lua75
1 files changed, 75 insertions, 0 deletions
diff --git a/durt/nodes/(-2227,8,292).lua b/durt/nodes/(-2227,8,292).lua
new file mode 100644
index 0000000..75c39d7
--- /dev/null
+++ b/durt/nodes/(-2227,8,292).lua
@@ -0,0 +1,75 @@
+--
+
+local delta = 4*60+20 -- HERE IS THE VALUE
+
+local owdata = S.BaHi_T6
+local numval = 5
+local switchbox_cp = { x=-2221,y=14,z=297}
+
+function save_delay(d)
+ if not owndata then
+ owndata = { false, false, false, false, false, false, false, false, }
+ end
+ for i=numval,2,-1 do
+ owndata[i] = owndata[i-1]
+ end
+ owndata[1] = d
+end
+
+function delay_text()
+ if not owndata then
+ return ""
+ end
+ local rg = ""
+ for i=1,numval do
+ h = owndata[i]
+ if not h then h = "" end
+ rg = rg .. h .." "
+ end
+ return rg
+end
+
+if event.type == "train" then
+ if atc_arrow then
+ atc_send("B0WOL") -- D20OCD3S2")
+-- setstate("BaHi_T5_S2","st")
+-- setstate("BaHi_T5_S1","st")
+
+ if not S.BaHi_T6 then
+ S.BaHi_T6 = os.time()
+ end
+-- interrupt(1,"departure")
+-- else
+ now = os.time()
+ tempdist = now-S.BaHi_T6
+ save_delay(tempdist)
+ delaystr = delay_text()
+ output = "last: "..S.BaHi_T6 .. "\nnow: " .. now .. "\ndelta: " .. tempdist.. "\n"..delta .. " " .. delaystr
+ digiline_send("lcd",output)
+ interrupt_pos( switchbox_cp, { action = "display", data = output } )
+ if tempdist > delta then
+ interrupt(15,"departure")
+ else
+ interrupt(-tempdist+delta,"departure")
+ end
+-- end
+ end
+ return
+end
+
+if event.type == "int" then
+ if event.msg == "departure" then
+ -- setstate("BaHi_T5_S2","st")
+ -- setstate("BaHi_T5_S1","st")
+ atc_set_text_inside("S23 -> Redwood")
+ atc_send("ROCD3S2")
+ now = os.time()
+ delaystr = delay_text()
+-- digiline_send("lcd","last: \nnow: " .. now .. "\ndelta: " .. tempdist.. "\n"..delta .. " " .. delaystr)
+ output = "last: " .. now .. " \n \n \n"..delta.." "..delaystr
+ digiline_send("lcd",output )
+ interrupt_pos( switchbox_cp, { action = "display", data = output } )
+ S.BaHi_T6 = now
+ end
+ return
+end \ No newline at end of file