Advertisement
Guest User

jarRefill

a guest
Aug 1st, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. -- Mana bean storage system - Computer Side.
  2. -- This needs to be connected to all jars using Peripheral Proxys and networking cables.
  3. -- Written by LKummer on the 24/2/2014.
  4.  
  5. local aspects = {"Aer", "Alienis", "Aqua", "Arbor", "Auram", "Bestia", "Cognitio", "Corpus", "Exanimis", "Fabrico", "Fames", "Gelum", "Granum", "Herba", "Humanus", "Ignis", "Instrumentum", "Iter", "Limus", "Lucrum", "Lux", "Machina", "Messis", "Metallum", "Meto", "Mortuus", "Motus", "Ordo", "Pannus", "Perditio", "Perfodio", "Permutatio", "Potentia", "Praecantatio", "Sano", "Saxum", "Sensus", "Spiritus", "Tlum", "Tempestas",
  6. "Enebrae", "Terra", "Tutamen", "Vacuos", "Venenum", "Victus", "Vunculum", "Vitium", "Vitreus", "Volatus"}
  7. local jarNames = peripheral.getNames()
  8.  
  9. local rID = "37" -- Receiver Turtle ID.
  10.  
  11. rednet.open("back")  -- Wired modem.
  12. rednet.open("right") -- Wireless modem.
  13.  
  14. while true do
  15.     for num, per in ipairs(jarNames) do -- Detect all connected peripherals using getNames().
  16.         if peripheral.getType(per) == "tt_aspectContainer" then -- Detect only the jars.
  17.             aspName = peripheral.call(per, "getAspects") -- Detect aspect.
  18.             aspNum = peripheral.call(per, "getAspectCount", aspName[1]) -- Detect aspect count.
  19.             if aspNum < 64 then -- Detect if aspect needs refilling.
  20.                 aspNumNeeded = 64 - aspNum -- Calculate how much mana beans it needs to send.
  21.                 for n, a in ipairs(aspects) do -- Conversion from aspect name to bean number for the Turtle.
  22.                     if a == peripheral.call(per, "getAspects") then
  23.                         for i = 1, aspNumNeeded do -- Repeat for how many beans needed to refill jar.
  24.                             rednet.close("back")
  25.                             rednet.broadcast(n)
  26.                             rednet.open("back")
  27.                             sleep(2.5)
  28.                         end
  29.                     end
  30.                 end
  31.             end
  32.         end
  33.     end
  34.     sleep(120)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement