Cardwell

Witherkill

Apr 9th, 2021 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. --Mottaker/Kontrollstasjon
  2. rednet.open("right")
  3. local R_HIGH_TEMP = 6
  4. local R_DMG_CRIT = 8
  5. local reaktorstatus = ""
  6. local REAKTOR_ON = "1"
  7. local REAKTOR_OFF = "2"
  8. local ALARM_OFF = "3"
  9.  
  10. while true do
  11. id, msg = rednet.receive()
  12. term.setCursorPos(1,1)
  13. print("1. For å starte reaktor")
  14. term.setCursorPos(1,2)
  15. print("2. For å stoppe reaktor")
  16. term.setCursorPos(1,3)
  17. print("3. For å skru av alarm")
  18. print("Reaktorstatus: ")
  19. print(reaktorstatus)
  20.  
  21. pw = read()
  22.  
  23. if id == R_HIGH_TEMP and msg == "HIGH_TEMP" then
  24. term.setCursorPos(1,5)
  25. print("Fra "..id)
  26. print("ADVARSEL! MELDING MOTTATT: HIGH_TEMP")
  27. print("ALARM PÅ!")
  28. rednet.broadcast("ALARM_ON")
  29. rednet.broadcast("REACTOR_OFF")
  30. print("REAKTOR SKRUDD AV")
  31. reaktorstatus = 0
  32. end
  33.  
  34. if id == R_DMG_CRIT and msg == "DMG_CRIT" then
  35. term.setCursorPos(1,5)
  36. print("Fra "..id)
  37. print("ADVARSEL! MELDING MOTTATT: DMG_CRIT")
  38. print("ALARM PÅ!")
  39. rednet.broadcast("ALARM_ON")
  40. rednet.broadcast("REACTOR_OFF")
  41. print("REAKTOR SKRUDD AV")
  42. reaktorstatus = 0
  43. end
  44.  
  45. if pw == REAKTOR_ON then
  46. rednet.broadcast("REACTOR_ON")
  47. reaktorstatus = 1
  48. term.clear()
  49. term.setCursorPos(1,1)
  50. print("Reaktor er skrudd på")
  51. sleep(1)
  52. end
  53.  
  54. if pw == REAKTOR_OFF then
  55. rednet.broadcast("REACTOR_OFF")
  56. reaktorstatus = 0
  57. term.clear()
  58. term.setCursorPos(1,1)
  59. print("Reaktor er skrudd av")
  60. sleep(1)
  61. end
  62.  
  63. end
Add Comment
Please, Sign In to add comment