Advertisement
Cardwell

ToggleRecieverV2

May 23rd, 2022 (edited)
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. --ToggleReciever
  2. rednet.open("bottom")
  3. local mottafra = 0
  4. local output = "back"
  5. local state = 0
  6. local ManualOn = 0
  7. local ManualOff = 0
  8.  
  9.  
  10. --function toggleOutput()
  11.  
  12.  
  13. while true do
  14.     term.clear()
  15.     UserInput = read()
  16.     term.setCursorPos(1,4)
  17.     print("Manual override, 1 or 0")
  18.     print("Status: ", state)
  19.     id, msg = rednet.receive()
  20.     print("")
  21.     print("Fra "..id)
  22.     print(msg)
  23.  
  24.     if id == mottafra and msg == "Spawner_ZombiePToggle" and state == 0 then
  25.         print("Spawner er på!")
  26.         rs.setOutput(output, true)
  27.         state = state + 1
  28.         print(state)
  29.  
  30.     elseif id == mottafra and msg == "Spawner_ZombiePToggle" and state == 1 then
  31.         print("Spawner er av!")
  32.         rs.setOutput(output, false)
  33.         state = state - 1
  34.         print(state)
  35.     end
  36.  
  37.     if UserInput == ManualOn then
  38.         state = 1
  39.         term.clear()
  40.         print("Manual on confirmed: ", state)
  41.         rs.setOutput(output, true)
  42.     end
  43.     if UserInput == ManualOff then
  44.         state = 0
  45.         term.clear()
  46.         print("Manual off confirmed: ", state)
  47.         rs.setOutput(output, false)
  48.     end
  49.     toggleOutput()
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement