Advertisement
meuced

TurtleDoor

Jul 16th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1. --tt = "droitegauchebas"
  2. --tt = "droitegauchehaut"
  3. tt = "centredroitebasethaut"
  4. tt = "centregauchebasethaut"
  5.  
  6. action = {
  7.     ["droitegauchebas"] = function ()
  8.         while true do
  9. --          print("go")
  10.             os.pullEvent("redstone")
  11.             if rs.getInput("back") == true and rs.getInput("back") ~= etatback then
  12.                 print("dans true")
  13.                 rs.setOutput("top", true)
  14.                 turtle.select(2)
  15.                 turtle.place()
  16.                 turtle.select(1)
  17.                 turtle.drop()
  18.                 sleep(0.5)
  19.                 local t = peripheral.wrap("front")
  20.                 t.turnOn()
  21.                 rs.setOutput("front", true)
  22.                 etatback = true
  23.             elseif rs.getInput("back") == false and rs.getInput("back") ~= etatback then
  24.                 print("dans false")
  25.                 rs.setOutput("top", false)
  26.                 turtle.select(1)
  27.                 rs.setOutput("front", false)
  28.                 sleep(2)
  29.                 turtle.dig()
  30.                 etatback = false
  31.             end
  32.         end
  33.     end ,
  34.  
  35.     ["droitegauchehaut"] = function ()
  36.         while true do
  37. --          print("go")
  38.             os.pullEvent("redstone")
  39.             if rs.getInput("bottom") == true and rs.getInput("bottom") ~= etatback then
  40.                 print("dans true")
  41.                 turtle.select(2)
  42.                 turtle.place()
  43.                 turtle.select(1)
  44.                 turtle.drop()
  45.                 local t = peripheral.wrap("front")
  46.                 t.turnOn()
  47.                 rs.setOutput("front", true)
  48. --              rs.setOutput("top", true)
  49.                 etatback = true
  50.             elseif rs.getInput("bottom") == false and rs.getInput("bottom") ~= etatback then
  51.                 print("dans false")
  52.                 turtle.select(1)
  53.                 rs.setOutput("front", false)
  54. --              rs.setOutput("top", false)
  55.                 sleep(2)
  56.                 turtle.dig()
  57.                 etatback = false
  58.             end
  59.         end
  60.     end ,
  61.  
  62.     ["centredroitebasethaut"] = function ()
  63.         while true do
  64. --          print("go")
  65.             os.pullEvent("redstone")
  66.             if rs.getInput("back") == true and rs.getInput("back") ~= etatback then
  67.                 print("dans true")
  68.                 turtle.turnRight()
  69.                 turtle.select(1)
  70.                 turtle.place()
  71.                 turtle.turnLeft()
  72.                 etatback = true
  73.             elseif rs.getInput("back") == false and rs.getInput("back") ~= etatback then
  74.                 print("dans false")
  75.                 turtle.select(1)
  76.                 turtle.turnRight()
  77.                 turtle.dig()
  78.                 turtle.turnRight()
  79.                 turtle.drop()
  80.                 etatback = false
  81.             end
  82.         end
  83.     end ,
  84.  
  85.     ["centregauchebasethaut"] = function ()
  86.         while true do
  87. --          print("go")
  88.             os.pullEvent("redstone")
  89.             if rs.getInput("back") == true and rs.getInput("back") ~= etatback then
  90.                 print("dans true")
  91.                 turtle.turnLeft()
  92.                 turtle.select(1)
  93.                 turtle.place()
  94.                 turtle.turnRight()
  95.                 etatback = true
  96.             elseif rs.getInput("back") == false and rs.getInput("back") ~= etatback then
  97.                 print("dans false")
  98.                 turtle.select(1)
  99.                 turtle.turnLeft()
  100.                 turtle.dig()
  101.                 turtle.turnLeft()
  102.                 turtle.drop()
  103.                 etatback = false
  104.             end
  105.         end
  106.     end
  107.  
  108.  
  109.  
  110.  
  111. }
  112.  
  113. local etatback = rs.getInput("back")
  114. local etatbottom = rs.getInput("bottom")
  115.  
  116. --a = read()
  117. action[tt]()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement