summaryrefslogtreecommitdiff
path: root/ywang
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-10-15 22:37:32 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-10-15 22:37:32 +0200
commit5c7f77725394d47ce0b907aabf885ea207a507bd (patch)
treea1ff9c67ef8f225a259e4c6f4c163a45c58bb870 /ywang
parentb435d1b1b26db6f7c4f3eb589ecf1ed3bb79b57e (diff)
downloadluaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.tar.gz
luaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.tar.bz2
luaatc_envs-5c7f77725394d47ce0b907aabf885ea207a507bd.zip
State at 2024-10-15
Diffstat (limited to 'ywang')
-rw-r--r--ywang/init_code.lua0
-rw-r--r--ywang/nodes/(1991,19,8251).lua35
2 files changed, 35 insertions, 0 deletions
diff --git a/ywang/init_code.lua b/ywang/init_code.lua
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ywang/init_code.lua
diff --git a/ywang/nodes/(1991,19,8251).lua b/ywang/nodes/(1991,19,8251).lua
new file mode 100644
index 0000000..740144a
--- /dev/null
+++ b/ywang/nodes/(1991,19,8251).lua
@@ -0,0 +1,35 @@
+local formats = {".%d", "+%d", "%d\t", "\t%d", "%d ", " %d", "%d\n", "\n%d", "-%d", "%d."}
+local len = #formats*10
+
+local function color(num)
+ return math.fmod(num*67+101, 255) + math.fmod(num*97+109, 255) + math.fmod(num*73+127, 255)
+end
+
+if not disco then
+ disco = 0
+end
+if not atc_id then
+ return
+end
+if event.type == "train" then
+ if not atc_id then return end
+ atc_send("B0")
+ disco = 0
+end
+if event.type == "train" or event.type == "schedule" then
+ local line = get_line()
+ if not line or line == "" or (line:len() == 2 and tonumber(line)) then
+ local digit, fmt, str
+ for _ = 1, 10 do
+ digit = math.floor(disco/#formats)
+ fmt = formats[disco%#formats+1]
+ str = fmt:format(digit)
+ disco = (disco+1)%len
+ if color(tonumber(str)) <= 512 then
+ break
+ end
+ end
+ set_line(str)
+ schedule_in(5)
+ end
+end \ No newline at end of file