Advertisement
GooGoo

dropCoal - ComputerCraft Turtle Program

Apr 21st, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. --[[
  2. Coal dropper for Botania mana generation.  version 1.0 by ThaWade.
  3. Use with checkMana program found > http://pastebin.com/Jgyf9zYE
  4. ]]
  5.  
  6. local count = 9 --change this to the number of Endoflames you're using.
  7. local sleepTime = 41-- sleep time between each coal drop.
  8. local inputSignal = "back"--The redstone input side.
  9. local firstSlot, lastSlot = 1,16
  10.  
  11. function clearTerm()
  12.     term.clear()
  13.     term.setCursorPos(1,1)
  14. end
  15.  
  16. function dropCoal()
  17.     print("Dropping coal...")
  18.     turtle.select(1)
  19.     turtle.dropDown(count)
  20.     sleep(sleepTime)
  21. end
  22.  
  23. function grabItems()
  24.     print("Grabbing items from external inventory.")
  25.     for g = 1,16 do
  26.         turtle.suck()
  27.     end
  28.     print("Done grabing items.")
  29. end
  30.  
  31. function moveItems()--simply moves items from slots 2 - 16 and places them in slot 1
  32.     print("Moving items...")
  33.     for i = 2, 16 do
  34.         turtle.select(i)
  35.         turtle.transferTo(1)
  36.     end
  37.     print("Done moving items.")
  38. end
  39.  
  40. function getCount()--makes sure there are enough items in slot one to drop.
  41.     if turtle. getItemCount(firstSlot,lastSlot) < count then
  42.         grabItems()
  43.     elseif turtle.getItemCount(1) < count then --if item count in slot 1 is less than amount configured to drop then
  44.         print("Not enough items in slot 1")
  45.         moveItems()-- we move items from slots 2 - 16 into slot one.
  46.     elseif turtle.getItemCount(1) >= count then--if item count in slot 1 is equal or greater than amount configured to then
  47.         print("Enough items in slot 1. Continuing work...")
  48.         dropCoal()--we proceed with droping the coal.
  49.     end
  50. end
  51.  
  52. function ifRedstoneSignal()
  53.     print("Checking redstone signal state...")
  54.     if redstone.getInput(inputSignal) == true then
  55.         print("Redstone signal present...")
  56.         getCount()
  57.     else
  58.     print("Redstone signal NOT present...")
  59.     print("Sleeping 60 seconds")
  60.     sleep(60)
  61.     end
  62. end
  63.  
  64. clearTerm()
  65.  
  66. while true do
  67.     ifRedstoneSignal()
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement