Cardwell

ToggleReciever

May 23rd, 2022 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. --ToggleReciever
  2. rednet.open("bottom")
  3. local mottafra = 0
  4. local output = "back"
  5. local state = 0
  6.  
  7.  
  8. function toggleOutput()
  9.     id, msg = rednet.receive()
  10.     print("")
  11.     print("Fra "..id)
  12.     print(msg)
  13.  
  14.     if id == mottafra and msg == "Spawner_ZombiePToggle" and state == 0 then
  15.         print("Spawner er pĆ„!")
  16.         rs.setOutput(output, true)
  17.         state = state + 1
  18.         print(state)
  19.  
  20.     elseif id == mottafra and msg == "Spawner_ZombiePToggle" and state == 1 then
  21.         print("Spawner er av!")
  22.         rs.setOutput(output, false)
  23.         state = state - 1
  24.         print(state)
  25.     end
  26. end
  27.  
  28. while true do
  29.     toggleOutput()
  30. end
Add Comment
Please, Sign In to add comment