moverperfect

murtle

Oct 4th, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. -- Murtle API
  2. -- By moverperfect
  3.  
  4. -- for more visit
  5. --
  6.  
  7. function fwd(n)
  8.     if n == nil then
  9.         n=1
  10.     end
  11.     for i=1, n do
  12.         while not turtle.forward() do
  13.             turtle.dig()
  14.         end
  15.     end
  16. end
  17.  
  18. function down(n)
  19.     if n == nil then
  20.         n=1
  21.     end
  22.     for i=1, n do
  23.         while not turtle.down() do
  24.             turtle.digDown()
  25.         end
  26.     end
  27. end
  28.  
  29. function up(n)
  30.     if n == nil then
  31.         n=1
  32.     end
  33.     for i=1, n do
  34.         while not turtle.up() do
  35.             turtle.digUp()
  36.         end
  37.     end
  38. end
  39.  
  40. function back(n)
  41.     if n == nil then
  42.         n=1
  43.     end
  44.     for i=1,n do
  45.         turtle.back()
  46.     end
  47. end
  48.  
  49. function left(n)
  50.     if n == nil then
  51.         n = 1
  52.     end
  53.     for i=1, n do
  54.         turtle.turnLeft()
  55.     end
  56. end
  57.  
  58. function right(n)
  59.     if n == nil then
  60.         n = 1
  61.     end
  62.     for i=1,n do
  63.         turtle.turnRight()
  64.     end
  65. end
  66.  
  67. function turnright()
  68.     turtle.turnRight()
  69.     fwd()
  70.     turtle.turnRight()
  71. end
  72.  
  73. function turnleft()
  74.     turtle.turnLeft()
  75.     fwd()
  76.     turtle.turnLeft()
  77. end
  78.  
  79. function place(s)
  80.     if s == nil then
  81.         turtle.place()
  82.     else
  83.         turtle.select(s)
  84.         if turtle.getItemCount(s) == 0 then
  85.             turtle.select(s+1)
  86.             if turtle.getItemCount(s+1) == 0 then
  87.                 turtle.select(s+2)
  88.                 turtle.place()
  89.             else
  90.                 turtle.place()
  91.             end
  92.         else
  93.             turtle.place()
  94.         end
  95.     end
  96. end
  97.  
  98. function placedown(s)
  99.     if s == nil then
  100.         turtle.placeDown()
  101.     else
  102.         turtle.select(s)
  103.         if turtle.getItemCount(s) == 0 then
  104.             turtle.select(s+1)
  105.             if turtle.getItemCount(s+1) == 0 then
  106.                 turtle.select(s+2)
  107.                 turtle.placeDown()
  108.             else
  109.                 turtle.placeDown()
  110.             end
  111.         else
  112.             turtle.placeDown()
  113.         end
  114.     end
  115. end
  116.  
  117. function placeup(s)
  118.     if s == nil then
  119.         turtle.placeUp()
  120.     else
  121.         turtle.select(s)
  122.         if turtle.getItemCount(s) == 0 then
  123.             turtle.select(s+1)
  124.             if turtle.getItemCount(s+1) == 0 then
  125.                 turtle.select(s+2)
  126.                 turtle.placeUp()
  127.             else
  128.                 turtle.placeUp()
  129.             end
  130.         else
  131.             turtle.placeUp()
  132.         end
  133.     end
  134. end
  135.  
  136. function checkeven(n)
  137.     if n % 2 == 0 then
  138.         return true
  139.     else
  140.         return false
  141.     end
  142. end
  143.  
  144. function dig(n)
  145.     if n == nil then
  146.         fwd(1)
  147.         turtle.digUp()
  148.         turtle.digDown()
  149.     else
  150.         for i=1,n do
  151.             fwd(1)
  152.             turtle.digUp()
  153.             turtle.digDown()
  154.         end
  155.     end
  156. end
  157.  
  158. function sbendr()
  159.     turtle.turnRight()
  160.     fwd(1)
  161.     turtle.turnLeft()
  162.     fwd(1)
  163. end
  164.  
  165. function sbendl()
  166.     turtle.turnLeft()
  167.     fwd(1)
  168.     turtle.turnRight()
  169.     fwd(1)
  170. end
Advertisement
Add Comment
Please, Sign In to add comment