View difference between Paste ID: TbnCGjHy and ksnHr3wK
SHOW: | | - or go back to the newest paste.
1
rednet.open("right")
2
-- c is the chest of mana beans
3
local c = peripheral.wrap("bottom")
4
-- a is the aspectylizer
5
local a = peripheral.wrap("front")
6
-- f is the furnace
7
local f = peripheral.wrap("front")
8
local redstoneDir = "back"
9
--Added this incase you are pastebinning the code
10
local beans = {}
11
12
function scanSlot(slot)
13
    c.pushItem("up", slot,1)
14
    turtle.drop()
15
    data = a.getAspects()
16
    beans[data] = slot
17
    print("Bean Scanned = "..data)
18
    turtle.suck()
19
    c.pullItemIntoSlot("up", 1, 1,slot)
20
end   
21
22
function scanSlots()
23
   redstone.setOutput(redstoneDir, true)
24
   for i = 1, 55 do
25
      if c.getStackInSlot(i) then
26
         scanSlot(i)
27
      end
28
   end
29
   redstone.setOutput(redstoneDir, false)
30
end
31
32
function essentia(aspect, numAspect)
33
  print("Aspect = "..aspect.." and Amount requested = "..numAspect)
34
  c.pushItemIntoSlot("up", beans[aspect], numAspect,1)
35
  mbit = turtle.getItemCount(1)  -- mbit = mana beans in turtle
36
  print("  Amount of beans retrieved = "..mbit)
37
  mbc = 0  -- mbc = mana beans in chest
38
  if mbit < numAspect then
39
    while (mbc + mbit) < numAspect do
40
      sleep(5)  -- wait for more manabeans from ME network
41
      ct = c.getStackInSlot(beans[aspect])
42
      if ct ~= nil then
43
        mbc = ct["qty"]
44
      else
45
        mbc = 0
46
      end -- end if
47
    end -- end while
48
  end
49
  c.pushItemIntoSlot("up", beans[aspect], numAspect - mbit,1)
50
  mbit = turtle.getItemCount(1)
51
  print("  Amount of beans retrieved after refil = "..mbit)
52
53
     
54
   redstone.setOutput("left", true)
55
   sleep(1)
56
   redstone.setOutput("left", false)
57
   sleep(3)
58
   turtle.dropUp()
59
   --f.pullItemIntoSlot("down", 1, numAspect,1)   
60
   sleep(3)
61
end
62
63
function awaitRednet()
64
  local id, msg, dist = rednet.receive()
65
  --term.write(msg)
66
  local essData = {}
67
  essData = textutils.unserialize(msg)
68
  print(essData[1]..":"..essData[2])
69
  essentia(essData[1], essData[2])
70
  rednet.send(id, "Complete")
71
end
72
73
scanSlots()
74
print("...SCAN COMPLET...")
75
while true do
76
   awaitRednet()
77
end
78
--essentia("lucrum", 1)