Advertisement
Guest User

lift

a guest
Jan 29th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. m = peripheral.wrap("front")
  2. m.open(3)
  3.  
  4.  
  5. function clear()
  6. sides = {"right","bottom"}
  7. for i=1,#sides do
  8. rs.setOutput(sides[i],false)
  9. end
  10. end
  11.  
  12. function getmss(me)
  13. a = {}
  14. for k,v in string.gmatch(me, "(%w+)=(%w+)") do
  15. if k == 1 then
  16. a[1] = v
  17. else
  18. a[2] = v
  19. end
  20. end
  21. return a[1],a[2]
  22. end
  23.  
  24. while true do
  25. local e,p1,p2,p3,me,p4 = os.pullEvent("modem_message")
  26. if me == "rsClear" then
  27. clear()
  28. else
  29. side,state = getmss(me)
  30. if state == "true" then
  31. rs.setOutput(side,true)
  32. else
  33. rs.setOutput(side,false)
  34. end
  35. end
  36.  
  37. if rs.getInput("left") then
  38. rs.setOutput("right",true)
  39. sleep(2)
  40. rs.setOutput("right",false)
  41. end
  42. sleep(2)
  43. if rs.getInput("back") then
  44. rs.setOutput("bottom",true)
  45. end
  46. sleep(1)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement