Advertisement
JohnnyNordx

Computercraft (Mining Turtle) - stairs building Turtle

Mar 20th, 2015
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. -- Program name : stairs building Turtle
  2. -- description  : with this program you can with a turtle digging stairs
  3. -- developer    : JohnnyNordx
  4. -- updated on   : 20-03-2015
  5.  
  6. function up()
  7.     turtle.up()
  8.     for ux=2, lay do
  9.         while turtle.detect() do
  10.             turtle.dig()
  11.         end
  12.         sleep(0.5)
  13.         if turtle.detect() then
  14.             while turtle.detect() do
  15.                 turtle.dig()
  16.                 sleep(0.5)
  17.             end
  18.         end
  19.         turtle.forward()
  20.         turtle.digUp()
  21.         turtle.digDown()
  22.         turtle.up()
  23.         turtle.digUp()
  24.     end
  25. end
  26.  
  27. function down()
  28.     -- 0 lay
  29.     turtle.digDown()
  30.     -- 1 lay
  31.     turtle.down()
  32.     while turtle.detect() do
  33.         turtle.dig()
  34.     end
  35.     sleep(0.5)
  36.     if turtle.detect() then
  37.         while turtle.detect() do
  38.             turtle.dig()
  39.             sleep(0.5)
  40.         end
  41.     end
  42.     turtle.forward()
  43.     turtle.digDown()
  44.     -- 2 lay
  45.     turtle.down()
  46.     while turtle.detect() do
  47.         turtle.dig()
  48.     end
  49.     sleep(0.5)
  50.     if turtle.detect() then
  51.         while turtle.detect() do
  52.             turtle.dig()
  53.             sleep(0.5)
  54.         end
  55.     end
  56.     turtle.forward()
  57.     turtle.digUp()
  58.     turtle.digDown()
  59.     while turtle.detect() do
  60.         turtle.dig()
  61.     end
  62.     sleep(0.5)
  63.     if turtle.detect() then
  64.         while turtle.detect() do
  65.             turtle.dig()
  66.             sleep(0.5)
  67.         end
  68.     end
  69.     -- 2-3 lay
  70.     turtle.forward()
  71.     turtle.digUp()
  72.     while turtle.detect() do
  73.         turtle.dig()
  74.     end
  75.     sleep(0.5)
  76.     if turtle.detect() then
  77.         while turtle.detect() do
  78.             turtle.dig()
  79.             sleep(0.5)
  80.         end
  81.     end
  82.     turtle.digDown()
  83.     -- 3 lay
  84.     turtle.down()
  85.     turtle.digDown()
  86.     lay = lay-3
  87.    
  88. for dx=2,lay do
  89.     while turtle.detect() do
  90.         turtle.dig()
  91.     end
  92.     sleep(0.5)
  93.     if turtle.detect() then
  94.         while turtle.detect() do
  95.             turtle.dig()
  96.             sleep(0.5)
  97.         end
  98.     end
  99.     turtle.forward()
  100.     turtle.digUp()
  101.     turtle.digDown()
  102.     turtle.dig()
  103.     turtle.down()
  104.     turtle.digDown()
  105.     end
  106. end
  107.  
  108. function fuel()
  109.     term.write("put fuel in slot 1 (if is more then 64 put it in next slot)")
  110.     line()
  111.     term.write("Press S to start")
  112.     while true do
  113.         local sEvent, param = os.pullEvent("key")
  114.         if sEvent == "key" then
  115.             if param == 31 then
  116.                 cl()
  117.                 print("Turtle Running")
  118.                 break
  119.             end
  120.         end
  121.     end
  122.     for slot=1,16 do
  123.         turtle.select(slot)
  124.         turtle.refuel()
  125.     end
  126. end
  127.  
  128. function cl()
  129. term.clear()
  130. lx = "0"
  131. line()
  132. end
  133.  
  134. function line()
  135. lx = lx+1
  136. term.setCursorPos(1,lx)
  137. end
  138.  
  139. lx = "0"
  140.  
  141. -- terminal menu
  142. cl()
  143. term.write("Stairs Building Turtle")
  144. line()
  145. term.write("Up = from below and if selected,")
  146. line()
  147. term.write("     right up to the sky")
  148. line()
  149. term.write("Down = from top and if selected,")
  150. line()
  151. term.write("       right down to the bedrock")
  152. line()
  153. line()
  154. term.write("Up/Down : ")
  155. term.setCursorBlink(true)
  156. ud = read()
  157.  
  158. if ud == "Up" or ud == "up" then
  159.     line()
  160.     term.write("how many layers ? : ")
  161.     lay = read()
  162.     fuel()
  163.     up()
  164. elseif ud == "Down" or ud == "down" then
  165.     line()
  166.     term.write("how many layers ? : ")
  167.     lay = read()
  168.     fuel()
  169.     down()
  170. else
  171.     os.reboot()
  172. end
  173. cl()
  174. write("completed")
  175. line()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement