Guest User

runes2

a guest
Jul 16th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. function pulse (side, colour)
  2.    print("pulse ", side, ": ", colour)
  3.    rs.setBundledOutput(side, colour)
  4.    sleep(0.4)
  5.    rs.setBundledOutput(side, 0)
  6. end
  7.  
  8. function checkItemComparator()
  9.   local level = rs.getAnalogInput("left")
  10.   print("item comparator: ", level)
  11.   return level
  12. end
  13.  
  14. function preCrafting()
  15.   -- pause to ensure all items get there
  16.   sleep(2)
  17.   -- a signal from below can be used to wait longer
  18.   while rs.getInput("bottom") == true do
  19.     print "locked: waiting 2 more seconds..."
  20.     sleep(2)
  21.   end
  22. end
  23.  
  24. function pumpItems()
  25.   local done = false
  26.   -- loop till all items in the chest are ejected
  27.   while done == false do
  28.     compLevel = checkItemComparator()
  29.     if compLevel > 0 then
  30.       -- white = vanilla dropper (items)
  31.       pulse("top", colors.white)
  32.     else
  33.       done = true
  34.     end
  35.   end
  36. end
  37.  
  38. function watchCrafting()
  39.   -- crafting has begun
  40.   -- wait for strength 2 signal to finish
  41.   -- runic altar's comparator outputs this
  42.   local finished = 0
  43.   for i = 0, 60 do
  44.     local altar = rs.getAnalogInput("back")
  45.     print("altar comparator: ", altar)
  46.     if altar == 2 then
  47.       pulse("top", colors.magenta)
  48.       finished = 1
  49.       break
  50.     end
  51.     sleep(1)
  52.   end
  53.   if finished == 0 then
  54.     print("ERROR: crafting didn't finish after 60 seconds")
  55.   end
  56. end
  57.  
  58. print "Botania Rune Crafter active!"
  59.  
  60. -- wait for a redstone signal from the input comparator
  61. while true do
  62.   print("waiting on a redstone event...")
  63.   os.pullEvent("redstone")
  64.  
  65.   if rs.getInput("left") == true then
  66.     print("got redstone event from chest!")
  67.     preCrafting()
  68.     if checkItemComparator() > 0 then
  69.       pumpItems()
  70.       sleep(0.5)
  71.       -- magenta = dispenser (wand of forest)
  72.       pulse("top", colors.magenta)
  73.       watchCrafting()      
  74.     end  -- if checkItemComparator
  75.   end -- if rs.getInput
  76. end  -- while true
Advertisement
Add Comment
Please, Sign In to add comment