Advertisement
Daraketh

TurtleFishMonger

Jun 9th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.64 KB | None | 0 0
  1. function startCheck()
  2.  
  3.     if (turtle.getFuelLevel() < 50) then
  4.    
  5.         getFuel()
  6.        
  7.     end
  8.    
  9.     turtle.select(1)
  10.    
  11. end
  12.  
  13. function fishCheck()
  14.  
  15.     turtle.suck()
  16.  
  17.     if ( turtle.compareTo(2) and turtle.getItemCount(1) == 64) then
  18.    
  19.         return true
  20.        
  21.     else
  22.    
  23.         turtle.drop() -- put wrong item/amount back into chest
  24.         return false
  25.        
  26.     end
  27.    
  28. end
  29.  
  30. function getCookedFish()
  31.  
  32.     turtle.turnLeft()
  33.     turtle.turnLeft()
  34.     turtle.forward()
  35.     turtle.forward()
  36.     turtle.forward()
  37.     turtle.forward()
  38.    
  39.     turtle.drop() -- dropped cooked fish in furnace chest
  40.    
  41.     turtle.turnRight()
  42.     turtle.forward()
  43.     turtle.forward()
  44.     turtle.forward()
  45.     turtle.forward()
  46.     turtle.turnLeft()
  47.    
  48.     getFish() -- get fish from cooked chest
  49.    
  50.     turtle.turnRight()
  51.     turtle.turnRight()
  52.     turtle.forward()
  53.     turtle.forward()
  54.     turtle.forward()
  55.     turtle.forward()
  56.    
  57.     turtle.drop() -- drop cooked fish into chest
  58.    
  59.     turtle.turnRight()
  60.     turtle.forward()
  61.     turtle.forward()
  62.     turtle.forward()
  63.     turtle.forward()
  64.     turtle.turnLeft()
  65.    
  66. end
  67.  
  68. function getFish()
  69.  
  70.     turtle.suck()
  71.  
  72.     if (turtle.getItemCount(1) < 64) then
  73.    
  74.         while ( turtle.getItemCount(1) < 64) do
  75.        
  76.                 turtle.drop()
  77.                 sleep(5)
  78.                 turtle.suck()
  79.                
  80.         end
  81.     end
  82.  
  83. end
  84.  
  85. function getFuel()
  86.  
  87.     turtle.turnLeft()
  88.     turtle.turnLeft()
  89.     turtle.forward()
  90.     turtle.forward()
  91.     turtle.turnLeft()
  92.     turtle.forward()
  93.     turtle.forward()
  94.     turtle.turnRight()
  95.     turtle.forward()
  96.     turtle.forward()
  97.    
  98.     turtle.select(16) -- select 16th slot to handle coal in
  99.    
  100.     while (turtle.getFuelLevel < 50) do -- Keep grabbing and consuming fuel until filled
  101.    
  102.     turtle.suck()
  103.     turtle.refuel()
  104.    
  105.         if (turtle.getItemCount(16) > 0) then
  106.        
  107.             turtle.drop() -- if there is any left over coal, drop it back in chest
  108.            
  109.         end
  110.    
  111.     end
  112.    
  113.     turtle.select(1) -- back to default slot
  114.    
  115.     turtle.turnLeft()
  116.     turtle.turnLeft()
  117.     turtle.forward()
  118.     turtle.forward()
  119.     turtle.turnLeft()
  120.     turtle.forward()
  121.     turtle.forward()
  122.     turtle.turnRight()
  123.     turtle.forward()
  124.     turtle.forward()
  125.    
  126. end
  127.  
  128.  
  129.  
  130. function main()
  131.  
  132.     startCheck() -- check everything is g (fuel)
  133.    
  134.     if(fishCheck()) then -- if it is raw fish, and the right amount
  135.    
  136.         getCookedFish() -- move between all the chest and provide cooked fish!
  137.    
  138.     end
  139.  
  140. end
  141.  
  142. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement