Advertisement
LeslieCraft

[HUN] Minecraft, computercraft turtle woodcutting

Aug 24th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. --Slot 1: Coal
  2. --Slot 2: Sepling
  3. --Slot 3: Bonemill
  4.  
  5. CoalSlot = 1
  6. SepSlot = 2
  7. BoneSlot = 3
  8. loop = true
  9.  
  10. function Refuel()
  11.     if turtle.getFuelLevel() < 1 then
  12.         turtle.select(CoalSlot)
  13.         if not turtle.refuel(2) then
  14.             print("Nem tudtam tankolni.")
  15.             read("")
  16.             return Refuel
  17.         end
  18.     end
  19. end
  20.  
  21. function cls()
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24. end
  25.  
  26. function PrintFuel(status)
  27.     cls()
  28.     local x, y = term.getCursorPos()
  29.     term.setCursorPos(x, y)
  30.     term.clearLine()
  31.     print("Time: " .. textutils.formatTime(os.time(),true))
  32.     local x, y = term.getCursorPos()
  33.     term.setCursorPos(x, y)
  34.     term.clearLine()
  35.     print("Fuel level: " .. turtle.getFuelLevel())
  36.     if status then
  37.         print("Working")
  38.     else
  39.         print("Stop")
  40.     end
  41. end
  42.  
  43. function GetBm()
  44.     turtle.select(BoneSlot)
  45.     return turtle.getItemCount(BoneSlot)
  46. end
  47.  
  48. function GetSe()
  49.     turtle.select(SepSlot)
  50.     return turtle.getItemCount(SepSlot)
  51. end
  52.  
  53. function CuttingWood()
  54.     if turtle.detect() then
  55.         turtle.select(4)
  56.         turtle.dig()
  57.         turtle.forward()
  58.         layer = 0
  59.         while turtle.detectUp() do
  60.             turtle.digUp()
  61.             turtle.up(1)
  62.             layer = layer + 1
  63.         end
  64.         for d = 0, layer do
  65.             turtle.down()
  66.         end
  67.         layer = 0
  68.         turtle.back()
  69.         return true
  70.     else
  71.         return false
  72.     end
  73. end
  74.  
  75. function GoWork()
  76.     for w = 0, 2 do
  77.         turtle.forward()
  78.     end
  79. end
  80.  
  81. function GoHome()
  82.     for b = 0, 2 do
  83.         turtle.back()
  84.     end
  85. end
  86.  
  87. function GetBone()
  88.     turtle.turnLeft(1)
  89.     turtle.select(BoneSlot)
  90.     turtle.suck()
  91.     turtle.suck()
  92.     turtle.suck()
  93.     turtle.suck()
  94.     turtle.turnRight(1)
  95. end
  96.  
  97. function GetSep()
  98.     turtle.turnRight(1)
  99.     turtle.select(SepSlot)
  100.     turtle.suck()
  101.     turtle.turnLeft(1)
  102. end
  103.  
  104. function wooding()
  105.     turtle.select(SepSlot)
  106.     turtle.place()
  107. end
  108.  
  109. function boneing()
  110.     turtle.select(BoneSlot)
  111.     for i = 0, 5 do
  112.         turtle.place()
  113.         sleep(.5)
  114.     end
  115. end
  116. function drop()
  117.     for i = 0, 1 do
  118.         turtle.turnRight()
  119.     end
  120.     for i = 4, 16 do
  121.         turtle.select(i)
  122.         turtle.drop()
  123.     end
  124.     for i = 0, 1 do
  125.         turtle.turnRight()
  126.     end
  127. end
  128.  
  129. function main()
  130.     Refuel()
  131.         PrintFuel(true)
  132.     GetBone()
  133.         PrintFuel(true)
  134.     GetSep()
  135.         PrintFuel(true)
  136.     GoWork()
  137.         PrintFuel(true)
  138.     wooding()
  139.         PrintFuel(true)
  140.     boneing()
  141.         PrintFuel(true)
  142.     CuttingWood()
  143.         PrintFuel(true)
  144.     GoHome()
  145.         PrintFuel(true)
  146.     drop()
  147.         PrintFuel(true)
  148. end
  149.  
  150. function stopCheck()
  151.     if redstone.getInput("bottom") then
  152.         return true
  153.     else
  154.         return false
  155.     end
  156. end
  157.  
  158. while loop do
  159.     while stopCheck() do
  160.         cls()
  161.         PrintFuel(true)
  162.         main()
  163.         delay = 0.1
  164.     end
  165.     delay = 2
  166.     cls()
  167.     PrintFuel(false)
  168.     sleep(delay)
  169. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement