Advertisement
Cardwell

ReaktorKontroll

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