akihex

plasticSurgery_fwd

Dec 3rd, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. --local plantName = "PneumaticCraft:heliumPlant"
  2. local plantName = "PneumaticCraft:flyingFlower"
  3. local plantMeta = 6
  4. local plantInvName = "PneumaticCraft:plasticPlant"
  5. --local plantInvMeta = 11
  6. local plantInvMeta = 15
  7. local delay = 2
  8. local smallDelay = 1
  9.  
  10. local seedSlot = 1
  11. turtle.select(seedSlot)
  12.  
  13. local function dumpSeeds(slotNr,num)
  14.   turtle.select(slotNr)
  15.   --turtle.drop(num)
  16.   turtle.dropDown(num)
  17.  -- turtle.select(seedSlot)
  18. end
  19.  
  20. local function checkInventory()
  21.   local item = nil
  22.   local count = 0
  23.   local seedFound = false
  24.   for i = 1,16 do
  25.     item = turtle.getItemDetail(i)
  26.     count = 0
  27.     if item and item.name == plantInvName and item.damage == plantInvMeta then
  28.       count = item.count
  29.       if seedFound == false then
  30.         if count > 1 then
  31.           dumpSeeds(i,count - 1)
  32.         end
  33.         seedSlot = i
  34.         --turtle.select(seedSlot)
  35.         seedFound = true
  36.       else
  37.         if count > 0 then
  38.           dumpSeeds(i,64)
  39.         end
  40.       end
  41.     end
  42.   end
  43.   turtle.select(seedSlot)
  44.   return seedFound
  45. end
  46.  
  47. local function waitForSeed()
  48.   local event, p1
  49.   local validInv = false
  50.   while not validInv do
  51.     event, p1 = os.pullEvent("turtle_inventory")
  52.     validInv = checkInventory()
  53.   end
  54. end
  55.  
  56. local function plantPlant()
  57.   local validInv = checkInventory()
  58.   --if not validInv then waitForSeed() end
  59.   --turtle.select(seedSlot)
  60.   local plantB,plantV = false,nil
  61.   --plantB,plantV = turtle.inspectUp()
  62.   plantB,plantV = turtle.inspect()
  63.   while plantB and plantV.name == plantName and plantV.metadata ~= plantMeta do
  64.     --plantB,plantV = turtle.inspectUp()
  65.     plantB,plantV = turtle.inspect()
  66.     sleep(delay)
  67.   end
  68.   if plantB and plantV.name == plantName and plantV.metadata == plantMeta then
  69.     --turtle.digUp()
  70.     turtle.dig()
  71.     validInv = checkInventory()
  72.   end
  73.   --plantB,plantV = turtle.inspectUp()
  74.   plantB,plantV = turtle.inspect()
  75.   if not validInv then waitForSeed() end
  76.   if not plantB then
  77.     --turtle.dropUp(1)
  78.     turtle.drop(1)
  79.     sleep(delay*2)
  80.   end
  81. end
  82.  
  83. while true do
  84.   --checkInventory()
  85.   plantPlant()
  86.   sleep(delay*2)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment