diff options
Diffstat (limited to 'pad')
| -rw-r--r-- | pad/init_code.lua | 71 | ||||
| -rw-r--r-- | pad/nodes/(-897,-8,-3153).lua | 29 | ||||
| -rw-r--r-- | pad/nodes/(-984,10,-3329).lua | 7 |
3 files changed, 107 insertions, 0 deletions
diff --git a/pad/init_code.lua b/pad/init_code.lua new file mode 100644 index 0000000..e0fbfdf --- /dev/null +++ b/pad/init_code.lua @@ -0,0 +1,71 @@ +if event.init then + local accounts = {} + S.acc = S.acc or accounts +end + +F.ack = function(n, c) + local r + local acc_n + + if n ~= nil and c ~= nil then + acc_n = S.acc and S.acc[n] + if acc_n then + r = S.acc[n][c] + end + + if r ~= nil and r > 0 then + S.acc[n][c] = S.acc[n][c] - 1 + end + end + + return r +end + +F.ick = function (m) + local wm, au, out, r + local a, b, c, d + + if m ~= nil then + a = m:find("\\u0003watermark\\u0002") + c = m:find("\\u0003owner\\u0002") + end + + if a ~= nil then + wm = m:sub(a+21) + end + + if c ~= nil then + au = m:sub(c+17) + end + + if wm ~= nil then + b = wm:find("\\u0003") + if b then + wm = wm:sub(1, b - 1) + end + end + + if au ~= nil then + d = au:find("\\u0003") + if d then + au = au:sub(1, d - 1) + end + if au and au:sub(-9) == "(printed)" then + au = au:sub(1, -11) + end + end + + if au ~= nil and wm ~= nil then + r = F.ack(au, wm) + else + return "ERR:Not a valid transport pass" + end + + if r ~= nil and r > 0 then + out = "ACC:" .. tostring(r-1) .. " remaining uses" + else + out = "ERR:No remaining uses. Please top-up." + end + + return out +end
\ No newline at end of file diff --git a/pad/nodes/(-897,-8,-3153).lua b/pad/nodes/(-897,-8,-3153).lua new file mode 100644 index 0000000..13b89b6 --- /dev/null +++ b/pad/nodes/(-897,-8,-3153).lua @@ -0,0 +1,29 @@ +local OPENER = {x=-897,y=-11,z=-3154} + +if event.type == "digiline" then + local catch = event + local prefix = catch.msg:sub(1, 4) + local message, r_prefix + + if catch.channel == "Lig" and prefix == "uput" then + message = F.ick(catch.msg) + + if message ~= nil then + r_prefix = message:sub(1, 3) + end + + if r_prefix ~= nil then + if r_prefix == "ACC" then + interrupt(5) + interrupt_pos(OPENER, "open") + end + digiline_send("pref_sc", message:sub(5)) + end + else + interrupt(5) + end +end + +if event.type == "int" then + digiline_send("pref_sc", "Please insert your transport pass below") +end
\ No newline at end of file diff --git a/pad/nodes/(-984,10,-3329).lua b/pad/nodes/(-984,10,-3329).lua new file mode 100644 index 0000000..e1a0de7 --- /dev/null +++ b/pad/nodes/(-984,10,-3329).lua @@ -0,0 +1,7 @@ +if event.type == "punch" then + if S.acc[event.name] ~= nil then +-- digiline_send("output", "You already own a transport\npass. You can use it at\nany station or top-up your\nrides at a selling point.") +-- else + digiline_send("commit", event.name) + end +end
\ No newline at end of file |
