Advertisement
Hiranus

Rainbow Tree Planter

Jun 24th, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. function Find_In_Inventory (name,count,damage)
  2.     for i=1,16 do
  3.         turtle.select(i)
  4.         slot = turtle.getItemDetail()
  5.         if slot ~= nil then
  6.             if slot["name"] == name then
  7.                 if count ~= nil then
  8.                     if slot["count"] >=count then
  9.                         if damage ~= nil then
  10.                             if slot["damage"] == damage then
  11.                                 return i
  12.                             end
  13.                         else
  14.                             return i
  15.                         end
  16.                     end
  17.                 else
  18.                     if damage ~= nil then
  19.                         if slot["damage"] == damage then
  20.                             return i
  21.                         end
  22.                     else
  23.                         return i
  24.                     end
  25.                 end
  26.             end
  27.         end
  28.     end
  29.     return nil
  30. end
  31. function Refuel (value)
  32.     while turtle.getFuelLevel()<=value do
  33.         fuel_slot = Find_In_Inventory ("minecraft:coal",nil,nil)
  34.         turtle.select(fuel_slot)
  35.         turtle.refuel(1)
  36.     end
  37. end
  38. function PlaceSquare()
  39.     for i=1,4 do
  40.     turtle.placeDown()
  41.     turtle.forward()
  42.     turtle.turnLeft()
  43.     end
  44. end
  45.  
  46. local rainbow_sapling
  47. local dirt
  48.  
  49. while true do
  50. local event = os.pullEvent()
  51.     if event == "redstone" and redstone.getInput("right", true) then
  52.             Refuel(50)
  53.             rainbow_sapling =  Find_In_Inventory ("ChromatiCraft:chromaticraft_block_rainbowsapling",4,nil)
  54.             dirt =  Find_In_Inventory ("minecraft:dirt",4,nil)
  55.             if rainbow_sapling ~= nil and dirt ~= nil then
  56.                 while turtle.detect() do
  57.                     sleep(1)
  58.                 end
  59.                 sleep(2)
  60.                 for fwd=1,3 do
  61.                     turtle.forward()
  62.                 end
  63.                 turtle.select(dirt)
  64.                 PlaceSquare()
  65.                 turtle.up()
  66.                 turtle.select(rainbow_sapling)
  67.                 PlaceSquare()
  68.                 for i=1,2 do
  69.                     turtle.turnLeft()
  70.                 end
  71.                 turtle.forward()
  72.                 turtle.down()
  73.                 for i=1,2 do
  74.                     turtle.forward()
  75.                 end
  76.                
  77.                 for i=1,2 do
  78.                     turtle.turnLeft()
  79.                 end
  80.             end
  81.     end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement