Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------
- -- Essence Monitor
- -----------------------
- -- By Jeffrey Alexander, aka Bomb Bloke.
- -----------------------
- -- Important variables:
- -----------------------
- local aspectNames = {"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","Telum","Tempestas","Tenebrae","Terra","Tutamen","Vacuos","Venenum","Victus","Vinculum","Vitium","Vitreus","Volatus"}
- local jar, unknownJars, countDown, mon, chest, furnace, xSize, ySize, myEvent, myTimer = {}, {}, 0
- -----------------------
- -- Functions:
- -----------------------
- local function drawTrimmings()
- mon.setBackgroundColour(colours.grey)
- mon.clear()
- mon.setTextColour(colours.black)
- mon.setBackgroundColour(colours.black)
- mon.setCursorPos(20,1)
- mon.clearLine()
- mon.setBackgroundColour(colours.lightGrey)
- mon.write(" Essences ")
- for i=1,17 do for j=0,2 do
- if i==17 and j==2 then break end
- mon.setCursorPos(1+j*17,i+2)
- mon.write(aspectNames[i+j*17])
- mon.write(string.rep(" ",16-#aspectNames[i+j*17]))
- end end
- end
- -----------------------
- -- Init:
- -----------------------
- do
- local peripherals = peripheral.getNames()
- for i=1,#peripherals do if peripheral.getType(peripherals[i]) == "monitor" then
- mon = peripheral.wrap(peripherals[i])
- mon.side = peripherals[i]
- elseif peripheral.getType(peripherals[i]) == "tilejar" then
- local jarTemp = peripheral.wrap(peripherals[i])
- local tempAspects = jarTemp.getAspects()
- if tempAspects then jar[tempAspects[1].name] = jarTemp else unknownJars[#unknownJars+1] = jarTemp end
- elseif peripheral.getType(peripherals[i]) == "gold" then
- chest = peripheral.wrap(peripherals[i])
- elseif peripheral.getType(peripherals[i]) == "container_alchemyfurnace" then
- furnace = peripheral.wrap(peripherals[i])
- end end
- end
- xSize, ySize = mon.getSize()
- myTimer = os.startTimer(0)
- drawTrimmings()
- -----------------------
- -- Main Program:
- -----------------------
- while true do
- myEvent = {os.pullEvent()}
- if myEvent[1] == "timer" and myEvent[2] == myTimer then
- mon.setTextColour(colours.black)
- mon.setBackgroundColour(colours.grey)
- mon.setCursorPos(35,19)
- if countDown > 0 then
- countDown = countDown - 1
- mon.write("Update in "..tostring(countDown).."s... ")
- else
- mon.write("Updating... ")
- if unknownJars then
- for i=1,table.maxn(unknownJars) do if unknownJars[i] then
- local tempAspects = unknownJars[i].getAspects()
- if tempAspects then
- jar[tempAspects[1].name] = unknownJars[i]
- unknownJars[i] = nil
- end
- end end
- if table.maxn(unknownJars) == 0 then unknownJars = nil end
- end
- local working, gap = false
- mon.setBackgroundColour(colours.white)
- local counter = 1
- for column = 14,49,17 do for row = 3,19 do
- mon.setCursorPos(column, row)
- if jar[aspectNames[counter]] then
- local tempAspects = jar[aspectNames[counter]].getAspects()
- if tempAspects then
- local num = tostring(tempAspects[1].quantity)
- if #tempAspects > 1 then print("Oddity with "..aspectNames[counter]) end
- mon.write(string.rep(" ",2-#num)..num)
- gap = 64 - tempAspects[1].quantity
- else
- if unknownJars then
- unknownJars[#unknownJars+1] = aspectNames[counter]
- else unknownJars = {aspectNames[counter]} end
- jar[aspectNames[counter]] = nil
- mon.write("??")
- gap = 64
- end
- else
- mon.write("??")
- gap = 64
- end
- gap = math.min(gap, chest.getStackInSlot(counter).qty - 1, 22)
- if gap > 0 and not working then
- chest.pushItemIntoSlot("south",counter,gap,1)
- working = true
- end
- counter = counter + 1
- if counter == 51 then break end
- end end
- --local missing = furnace.getStackInSlot(2)
- --gap = math.min(chest.getStackInSlot(81).qty - 1, missing and (64-missing.qty) or 64)
- --print("will try to move "..gap.." fuel")
- --if gap > 0 then furnace.pullItemIntoSlot("north",81,gap,2) end
- countDown = 60
- end
- myTimer = os.startTimer(1)
- elseif myEvent[1] == "monitor_resize" and myEvent[2] == mon.side then
- xSize, ySize = mon.getSize()
- drawTrimmings()
- myTimer = os.startTimer(0)
- elseif myEvent[1] == "key" and (myEvent[2] == keys.q or myEvent[2] == keys.x) then
- os.pullEvent("char")
- error()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement