Advertisement
robocyclone

Untitled

Nov 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. local state = false
  2. term.setBackgroundColor(colors.red)
  3. term.clear()
  4. rs.setOutput("back", true)
  5.  
  6. function main()
  7. while true do
  8. if state then
  9. term.setBackgroundColor(colors.green)
  10. term.clear()
  11. rs.setOutput("back", false)
  12. turtle.attack()
  13. elseif not state then
  14. term.setBackgroundColor(colors.red)
  15. term.clear()
  16. rs.setOutput("back", true)
  17. end
  18. os.sleep(.1)
  19. end
  20. end
  21.  
  22. function swap()
  23. repeat
  24. local ev, b, x, y = os.pullEvent("mouse_click")
  25. until b
  26. state = not state
  27. return
  28. end
  29.  
  30. while true do
  31. parallel.waitForAny(main, swap)
  32. os.sleep(.1)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement