Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chestSide = "back"
- furtvSide = "west"
- furSide = "top"
- aspSide = "left"
- asptvSide = "east"
- modemSide = "front"
- tlocSide = "bottom"
- controlID = 24
- golemTravel = 5
- alembics = {}
- slot = {}
- itemName = "Ethereal Essence"
- alembicType = "tilesiphon"
- ch = peripheral.wrap(chestSide)
- as = peripheral.wrap(aspSide)
- fr = peripheral.wrap(furSide)
- rednet.open(modemSide)
- ---------functions---------
- function getRemotePeripherals()
- perID = peripheral.getNames()
- for i, n in pairs(perID) do
- if (peripheral.getType(n) == alembicType) then
- table.insert(alembics, peripheral.wrap(n))
- end
- end
- end
- function cleanChest()
- for i = 1, 54 do
- if (ch.getStackInSlot(i) ~= nil) then
- if (ch.getStackInSlot(i).name ~= itemName) then
- ch.destroyStack(i)
- end
- end
- end
- ch.condenseItems()
- end
- function cleanSystem()
- ch.condenseItems()
- filled = table.getn(ch.getAllStacks())
- if (filled >= (ch.getInventorySize() - 1)) then
- cleanChest()
- end
- ch.pullItem(furtvSide, 1)
- ch.pullItem(asptvSide, 1)
- cleanChest()
- end
- function buildAspectMap()
- rs.setOutput(tlocSide, true)
- for i = 1, 51 do
- if (ch.getStackInSlot(i) ~= nil) then
- ch.pushItem(asptvSide, i, 1)
- asp1, asp2 = as.getAspects()
- if (asp2 == "auram") then
- asp2 = asp1
- end
- if (asp2 == nil) then
- asp2 = "auram"
- end
- ch.pullItem(asptvSide, 1, 1, i)
- slot[asp2] = i
- end
- end
- rs.setOutput(tlocSide, false)
- end
- function alembicsEssenceCount()
- for t, al in pairs(alembics) do
- if (al.getAspects()[1] ~= nil) then
- return true
- end
- end
- return false
- end
- function getRequest()
- print("Listening")
- id, msg = rednet.receive()
- if (id == controlID) then
- print("Received request")
- data = textutils.unserialize(msg)
- if (data.asp == "auram") then
- itemCount = math.ceil(data["amount"] / 4)
- else
- itemCount = math.ceil(data["amount"] / 2)
- end
- if (itemCount >= ch.getStackInSlot(slot[data.asp]).qty) then
- itemCount = ch.getStackInSlot(slot[data.asp]).qty - 1
- end
- print("Pushing " .. itemCount .. " " .. data["asp"] .. " from " .. slot[data["asp"]])
- process(slot[data.asp], itemCount)
- rednet.send(id, "done")
- end
- end
- function process(slot, cnt)
- while (cnt > 0) do
- cnt = cnt - ch.pushItem(furtvSide, slot, cnt, 1)
- end
- while ((fr.getStackInSlot(1)) or alembicsEssenceCount()) do
- sleep(1)
- end
- sleep(golemTravel)
- print("Request completed")
- end
- ---------------------------
- print("Start")
- cleanSystem()
- print("System ready")
- buildAspectMap()
- print("Map built")
- getRemotePeripherals()
- print("Remote peripherals wrapped")
- while true do
- getRequest()
- end
Advertisement
Add Comment
Please, Sign In to add comment