Advertisement
PeachGaming

Test World Signalling

Feb 12th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. local signalID = "TLS1"
  2. local signalStatus = false
  3. local br = peripheral.wrap("back")
  4. if fs.exists("encrypt") then
  5. else
  6. shell.run("pastebin","get", "WRTfH0yx", "encrypt")
  7. end
  8.  
  9. if fs.exists("net") then
  10. else
  11. shell.run("pastebin", "get", "EX4jfhA8", "net")
  12. end
  13. os.loadAPI("encrypt")
  14. os.loadAPI("net")
  15. net.connect("PCS1", "Rifty")
  16. br.setBundledOutput(0)
  17. term.setTextColor(colors.green)
  18. print("Railway block "..signalID.." is active..")
  19. term.setTextColor(colors.white)
  20.  
  21.  
  22. local function dewSignalling()
  23. while true do
  24. sleep(0.5)
  25.  
  26. --Do the signalling for the line.
  27. if br.testBundledInput(colors.red) and signalStatus == false then
  28. signalStatus = true
  29. print("Train coming south..")
  30. br.setBundledOutput(colors.combine(br.getBundledOutput(), colors.lime))
  31. local send = encrypt.encrypt({signalID = signalID, status = signalStatus}, "nowimafurryrawr")
  32. net.send("signalUpdate|"..send, 49)
  33. local fs = fs.open("signalStatus", "w")
  34. fs.write(signalStatus)
  35. fs.close()
  36.  
  37. end
  38.  
  39. if br.testBundledInput(colors.orange) then
  40. signalStatus = false
  41. print("Train coming north..")
  42. br.setBundledOutput(colors.subtract(br.getBundledOutput(), colors.lime))
  43. local send = encrypt.encrypt({signalID = signalID, status = signalStatus}, "nowimafurryrawr")
  44. net.send("signalUpdate|"..send, 49)
  45. local fs = fs.open("signalStatus", "w")
  46. fs.write(signalStatus)
  47. fs.close()
  48. end
  49. end
  50.  
  51. end
  52.  
  53. local function dewRednetStuff()
  54.  
  55. end
  56.  
  57.  
  58.  
  59. dewSignalling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement