Advertisement
GooGoo

dropCoalv2 - ComputerCraft Turtle Program

Apr 24th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. --[[
  2. Coal dropper for Botania mana generation.  version 2.0 by ThaWade.
  3. Use with checkMana program found > http://pastebin.com/Jgyf9zYE
  4.  
  5. Default setup is: Redstone Input:Back, Item Container:Front
  6. ]]
  7.  
  8. local dropCount = 49--change this to the number of Endoflames you're using.
  9. local sleepTime = 44-- sleep time between each coal drop.
  10. local inputSignal = "back"--The redstone input side.
  11. local grabCount = 0
  12.  
  13. function clearTerm()
  14.     term.clear()
  15.     term.setCursorPos(1,1)
  16. end
  17.  
  18. function grabItems()
  19. local dropSlotCount = turtle.getItemCount(1)
  20. local maxCount = 64
  21.     print("Grabbing Items from external inventory")
  22.     turtle.select(1)
  23.     local grabCount = maxCount - dropSlotCount
  24.     if turtle.suck(grabCount) == true then
  25.         print("Done grabbing items")
  26.     elseif turtle.suck(grabCount) == false then
  27.         print("Nothing to grab items from")
  28.     end
  29. end
  30.  
  31. function dropCoal()
  32.     turtle.select(1)
  33.     print("Dropping coal...")
  34.     if dropCount > 32 then
  35.         turtle.dropDown(dropCount)
  36.         grabItems()
  37.         turtle.dropDown(dropCount)
  38.     elseif dropCount <= 32 then
  39.         turtle.dropDown(dropCount)
  40.     end
  41.     print("Done dropping coal...")
  42.     print("Sleeping " ..sleepTime.. " seconds.")
  43.     sleep(sleepTime)
  44. end
  45.  
  46. clearTerm()
  47.  
  48. while true do
  49. clearTerm()
  50.     if turtle.getItemCount(1) >= dropCount then
  51.         if redstone.getInput(inputSignal) == true then
  52.             print("Redstone signal present...")
  53.             dropCoal()
  54.         elseif redstone.getInput(inputSignal) == false then
  55.             print("Redstone signal NOT present...")
  56.             print("Sleeping 60 seconds")
  57.             sleep(60)
  58.         end
  59.     elseif turtle.getItemCount(1) < dropCount then
  60.             z = turtle.getItemCount(2)
  61.         if z > 0 then
  62.             turtle.select(2)
  63.             turtle.transferTo(1)
  64.         end
  65.             if z == 0 then
  66.                 grabItems()
  67.             end
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement