Advertisement
Clem105

Turtle Day

Oct 5th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. function On()
  2.     turtle.select(1)
  3.     turtle.digUp()
  4.     turtle.select(2)
  5.     turtle.placeUp()
  6.     rs.setOutput("top",true)
  7. end
  8. function Off()
  9.     rs.setOutput("top",false)
  10.     turtle.select(2)
  11.     turtle.digUp()
  12.     turtle.select(1)
  13.     turtle.placeUp()
  14. end
  15. function Write()
  16.     local h = fs.open("Etat","w")
  17.     h.write(Etat)
  18.     h.close()
  19.     end
  20. local modem = peripheral.wrap("left")
  21. local Chanel = 1505
  22. modem.open(Chanel)
  23. local  h = fs.open("Sauvegarde","r")
  24. local Etat = "set"
  25. while true do
  26.     local Event,Side, SenderChanel, ReplyChanel , Message, Distance = os.pullEvent("modem_message")
  27.     if Event == "modem_message" and  SenderChanel == Chanel then
  28.         if Message == "Set" then
  29.             Etat = h.readAll()
  30.             h.close()
  31.             if Etat == "On" then
  32.                 Write()
  33.                 On()
  34.             elseif Etat == "Off" then
  35.                 Write()
  36.                 Off()
  37.             end
  38.         elseif Message == "On" then
  39.             Etat = Message
  40.             Write()
  41.             On()
  42.         elseif Message == "Off" then
  43.             Etat = Message
  44.             Write()
  45.             Off()
  46.         end
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement