FoxWorn3365

ACC - Slave

Apr 25th, 2026 (edited)
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. -- ACC - Programma slave (attuatore)
  2. -- (c) 2026 FoxWorn3365 (Federico Cosma) per conto di interSex S.p.A.
  3.  
  4. function split(inputstr, sep)
  5.   if sep == nil then
  6.     sep = "%s"
  7.   end
  8.   local t = {}
  9.   for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  10.     table.insert(t, str)
  11.   end
  12.   return t
  13. end
  14.  
  15. -- Handshake - we download important data rn
  16. local h = http.get("https://rgr.rgbcraft.com/acc/proxy_handshake.php")
  17. raw_cdbs = h.readAll()
  18. h.close()
  19.  
  20. print(raw_cdbs)
  21.  
  22. -- 1 - 2
  23. signalBoxes = { peripheral.wrap("left"), peripheral.wrap("right") }
  24. cdbs = split(raw_cdbs, "@")
  25.  
  26. -- Loop - we define the clock
  27. clock = 0.5
  28.  
  29. function getStatusAtPos(t)
  30.    return signalBoxes[tonumber(t[4])].get(tonumber(t[1]),tonumber(t[2]),tonumber(t[3]))
  31. end
  32.  
  33. function setStatusAtPos(t)
  34.     signalBoxes[tonumber(t[4])].set(t[5],tonumber(t[1]),tonumber(t[2]),tonumber(t[3]))
  35. end
  36.  
  37. while true do
  38.     print("ACC Loop...")
  39.     -- Build status of CdBs
  40.     local status = ""
  41.     for i, v in ipairs(cdbs) do
  42.         local cdb = split(v, ",")
  43.         local cdbStatus = getStatusAtPos(cdb)
  44.         status = status..cdbStatus.."@"
  45.     end
  46.  
  47.     -- Send request
  48.     local h = http.post("https://rgr.rgbcraft.com/acc/proxy_acc.php", status)
  49.     raw_cmds = h.readAll()
  50.     h.close()
  51.  
  52.     -- Elaborate commands
  53.     cmds = split(raw_cmds, "@")
  54.    
  55.     for i, v in ipairs(cmds) do
  56.         print("ChangeStatus!!!"..v)
  57.         setStatusAtPos(split(v, ","))
  58.     end
  59.    
  60.     sleep(clock)
  61. end
Advertisement
Add Comment
Please, Sign In to add comment