Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.81 KB | None | 0 0
  1. local xx = 1
  2. local yy = 1
  3. local zz = 1
  4. local face = ""
  5. io.write("x, y, z, face (form: '+x' or '-y') Hit enter after each variable")
  6. xx = tonumber(io.read())
  7. yy = tonumber(io.read())
  8. zz = tonumber(io.read())
  9. face = tostring(io.read())
  10. function twobytwo(x, y)
  11.     goTo(x, y, 50)
  12.     turn("+x")
  13.     shaft("down")
  14.     forwardOne()
  15.     xx = xx + 1
  16.     turtle.turnRight()
  17.     forwardOne()
  18.     yy = yy - 1
  19.     turtle.turnRight()
  20.     shaft("up")
  21. end
  22. function turn(dir)
  23.     function r()
  24.         turtle.turnRight()
  25.     end
  26.     function l()
  27.         turtle.turnLeft()
  28.     end
  29.     if (face == "-x") then
  30.         if (dir == "-x") then
  31.         end
  32.         if (dir == "+x") then
  33.             r()
  34.             r()
  35.         end
  36.         if (dir == "-y") then
  37.             l()
  38.         end
  39.         if (dir == "+y") then
  40.             r()
  41.         end
  42.     end
  43.     if (face == "+x") then
  44.         if (dir == "-x") then
  45.             r()
  46.             r()
  47.         end
  48.         if (dir == "+x") then
  49.         end
  50.         if (dir == "-y") then
  51.             r()
  52.         end
  53.         if (dir == "+y") then
  54.             l()
  55.         end
  56.     end
  57.     if (face == "-y") then
  58.         if (dir == "-x") then
  59.             r()
  60.         end
  61.         if (dir == "+x") then
  62.             l()
  63.         end
  64.         if (dir == "-y") then
  65.         end
  66.         if (dir == "+y") then
  67.             r()
  68.             r()
  69.         end
  70.     end
  71.     if (face == "+y") then
  72.         if (dir == "-x") then
  73.             l()
  74.         end
  75.         if (dir == "+x") then
  76.             r()
  77.         end
  78.         if (dir == "-y") then
  79.             r()
  80.             r()
  81.         end
  82.         if (dir == "+y") then
  83.         end
  84.     end
  85.     face = dir
  86. end
  87. function goTo(x, y, z)
  88.     if (zz >= 50) then
  89.         local h = zz
  90.         for i = 1, (h - 50) do
  91.             turtle.digDown()
  92.             turtle.down()
  93.             zz = zz -1
  94.         end
  95.     end
  96.     if (zz < 50) then
  97.         local h = zz
  98.         for i = 1, (50 - h) do
  99.             oneUp()
  100.         end
  101.     end
  102.     if(xx >= x) then
  103.         turn("-x")
  104.         for i = 1, (xx - x) do
  105.             forwardOne()
  106.             xx = xx - 1
  107.         end
  108.     end
  109.     if(xx < x) then
  110.         turn("+x")
  111.         for i = 1, (x - xx) do
  112.             forwardOne()
  113.             xx = xx + 1
  114.         end
  115.     end
  116.     if(yy >= y) then
  117.         turn("-y")
  118.         for i = 1, (yy - y) do
  119.             forwardOne()
  120.             yy = yy -1
  121.         end
  122.         face = "-y"
  123.     end
  124.  
  125.     if(yy < y) then
  126.         turn("+y")
  127.         for i = 1, (y - yy) do
  128.             forwardOne()
  129.             yy = yy + 1
  130.         end
  131.         face = "+y"
  132.     end
  133.     if (z < 50) then
  134.         for i = 1, (50 - z) do
  135.             oneUp()
  136.         end
  137.     end
  138.     if (z > 50) then
  139.         for i = 0, (z - 50) do
  140.             turtle.digDown()
  141.             turtle.down()
  142.             zz = zz - 1
  143.         end
  144.     end
  145. end
  146. function shaft(direction)
  147.     if (direction == "down") then
  148.         local h = zz
  149.         for i = 1, h do
  150.             turtle.digDown()
  151.             turtle.down()
  152.             zz = zz - 1
  153.             if (turtle.compare() == false) then
  154.                 turtle.dig()
  155.             end
  156.         end
  157.     end
  158.     if (direction == "up") then
  159.         local h = zz
  160.         for i = 1, h do
  161.             oneUp()
  162.             if (turtle.compare() == false) then
  163.                 turtle.dig()
  164.             end
  165.         end
  166.     end
  167. end
  168. function forwardOne()
  169.     local test = turtle.forward()
  170.     while (test == false) do
  171.         turtle.dig()
  172.         test = turtle.forward()
  173.     end
  174. end
  175. function oneUp()
  176.     local test = turtle.up()
  177.     while (test == false) do
  178.         turtle.digUp()
  179.         test = turtle.up()
  180.     end
  181.     zz = zz + 1
  182. end
  183. twobytwo(xx, yy)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement