diff options
Diffstat (limited to 'ywang')
-rw-r--r-- | ywang/init_code.lua | 0 | ||||
-rw-r--r-- | ywang/nodes/(1991,19,8251).lua | 35 |
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 |