FoxWorn3365

ACC - Manager

Feb 19th, 2025 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. modem_pos = "front"
  2. deviatoi_pos = "top"
  3. partenza_pos = "left"
  4. stati_pos = "right"
  5. protezioni_pos = "bottom"
  6.  
  7. rednet.open(modem_pos)
  8.  
  9. -- Costanti
  10. -- >> BINARI
  11. binari = {[colors.lime] = false, [colors.yellow] = false, [colors.lightBlue] = false, [colors.magenta] = false, [colors.orange] = false, [colors.white] = false, [colors.pink] = false, [colors.gray] = false}
  12.  
  13. function getTrackStatus()
  14. for k, v in pairs(binari) do
  15. print(k)
  16. binari[k] = rs.testBundledInput(stati_pos, k)
  17. end
  18. end
  19.  
  20. function executeOrders(data, tableName, side)
  21. if data ~= nil and data[tableName] ~= nil then
  22. rs.setBundledOutput(side, data[tableName])
  23. end
  24. end
  25.  
  26. term.clear()
  27. term.setCursorPos(1, 1)
  28. print("ACC v1.0 [ATTUATORE] by FoxWorn3365 -- (C) 2025 ALSTOM\n\n")
  29.  
  30. -- Il programma lavora in sync con il computer del QlV
  31. -- Il messaggio deve contenere le istruzioni per TUTTO e noi come risposta inviamo le info dei binari occupati
  32. while true do
  33. print("[INFO] Awaiting message...")
  34. local sender, message = rednet.receive()
  35. if message ~= "" then
  36. local orders = textutils.unserialize(message)
  37. if #orders >= 1 then
  38. print("[INFO] Executing orders...")
  39. executeOrders(orders, "deviatoi", deviatoi_pos)
  40. executeOrders(orders, "partenza", partenza_pos)
  41. executeOrders(orders, "protezioni", protezioni_pos)
  42. end
  43. end
  44. print("[INFO] Sending CdB status list...")
  45. getTrackStatus()
  46. rednet.send(sender, textutils.serialize(binari))
  47. end
Advertisement
Add Comment
Please, Sign In to add comment