Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ACC - Programma slave (attuatore)
- -- (c) 2026 FoxWorn3365 (Federico Cosma) per conto di interSex S.p.A.
- function split(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t = {}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- -- Handshake - we download important data rn
- local h = http.get("https://rgr.rgbcraft.com/acc/proxy_handshake.php")
- raw_cdbs = h.readAll()
- h.close()
- print(raw_cdbs)
- -- 1 - 2
- signalBoxes = { peripheral.wrap("left"), peripheral.wrap("right") }
- cdbs = split(raw_cdbs, "@")
- -- Loop - we define the clock
- clock = 0.5
- function getStatusAtPos(t)
- return signalBoxes[tonumber(t[4])].get(tonumber(t[1]),tonumber(t[2]),tonumber(t[3]))
- end
- function setStatusAtPos(t)
- signalBoxes[tonumber(t[4])].set(t[5],tonumber(t[1]),tonumber(t[2]),tonumber(t[3]))
- end
- while true do
- print("ACC Loop...")
- -- Build status of CdBs
- local status = ""
- for i, v in ipairs(cdbs) do
- local cdb = split(v, ",")
- local cdbStatus = getStatusAtPos(cdb)
- status = status..cdbStatus.."@"
- end
- -- Send request
- local h = http.post("https://rgr.rgbcraft.com/acc/proxy_acc.php", status)
- raw_cmds = h.readAll()
- h.close()
- -- Elaborate commands
- cmds = split(raw_cmds, "@")
- for i, v in ipairs(cmds) do
- print("ChangeStatus!!!"..v)
- setStatusAtPos(split(v, ","))
- end
- sleep(clock)
- end
Advertisement
Add Comment
Please, Sign In to add comment