Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local meControllerSide = 'top'
- local meInterfaceSide = 'back'
- -- Install the F library if not present.
- if fs.exists('lib/f') == false then
- fs.makeDir("lib") lib = http.get("https://raw.githubusercontent.com/acidjazz/drmon/master/lib/f.lua") libFile = lib.readAll() local file1 = fs.open("lib/f", "w") file1.write(libFile) file1.close()
- end
- os.loadAPI("lib/f")
- --monitor
- local mon, monitor, monX, monY
- --peripherals
- local meController = peripheral.wrap(meControllerSide)
- local meInterface = peripheral.wrap(meInterfaceSide)
- --vars
- params = {meController = meController, meInterface = meInterface}
- if meInterface == null then
- error("No valid ME Interface was found on " .. meControllerSide .. " of computer.")
- end
- if meController == null then
- error("No valid ME Controller was found on ".. meInterfaceSide .." of computer. ")
- end
- if monitor == null then
- error("No valid monitor was found")
- end
- monitor.setTextScale(0.99)
- monX, monY = monitor.getSize()
- mon = {}
- mon.monitor,mon.X, mon.Y = monitor, monX, monY
- function showTabMenu(mon, currentTab)
- local y = 0
- local tabs = {Monitor=1,Details=11,Edit=21}
- for k,v in pairs(tabs) do
- if k == currentTab then
- f.draw_text(mon, v, y, '[' .. k .. ']', colors.white, colors.purple)
- else
- f.draw_text(mon, v, y, '[' .. k .. ']', colors.white, colors.gray)
- end
- end
- end
- function switchToTab(mon, tab, params)
- --erase screen, go to the main tab.
- f.clear(mon)
- showTabMenu(mon, tab);
- end
- function monitorTab(mon, params)
- print('Monitor general status')
- print ('Busy CPUs: ' .. getBusyCPUs(params.meController);)
- print ('Total CPUs: ' .. #params.meController.getCraftingCPUs())
- --[[
- [Monitor] [Details] [Edit]
- Monitor general crafting.
- Num total crafting jobs: 7
- Num computer jobs: 6
- Crafting requested:
- 64k ME storage
- Energetic Alloy
- and 4 others.
- ]]--
- end
- function getBusyCPUs(meController)
- local cpus = meController.getCraftingCPUs()
- local busy = 0;
- for cpu in ipairs(cpus) do
- if cpu.busy == true then
- busy++
- end
- end
- return busy
- end
- function drawButtons(y)
- -- 2-4 = -1000, 6-9 = -10000, 10-12,8 = -100000
- -- 17-19 = +1000, 21-23 = +10000, 25-27 = +100000
- f.draw_text(mon, 2, y, " < ", colors.white, colors.gray)
- f.draw_text(mon, 6, y, " <<", colors.white, colors.gray)
- f.draw_text(mon, 10, y, "<<<", colors.white, colors.gray)
- f.draw_text(mon, 17, y, ">>>", colors.white, colors.gray)
- f.draw_text(mon, 21, y, ">> ", colors.white, colors.gray)
- f.draw_text(mon, 25, y, " > ", colors.white, colors.gray)
- end
- --Program actually starts here.
- switchToTab(mon, 'Monitor', {})
- --[[
- [Monitor] [Details] [Edit]
- Monitor general crafting.
- Num total crafting jobs: 7
- Num computer jobs: 6
- Crafting requested:
- 64k ME storage
- Energetic Alloy
- and 4 others.
- --============================
- [Monitor] [Details] [Edit]
- Detailed Crafting breakdown
- Crafting Requested (Have / Want):
- 64k ME storage 5 / 64
- Energetic Alloy 64 / 256
- Steel Ingot 60 / 64
- ...
- ...
- --============================
- [Monitor] [Details] [Edit]
- Edit preferred stock levels.
- Recipe:
- 64k ME Storage
- Have: 5
- Want: 0
- Less - More
- <<< << < > >> >>>
- [Prev] [Next]
- ]]--
- -- What if there are no crafting CPUs free?
- -- What if there are not enough materials?
- -- What if the job is already running?
- -- What if the ME system runs out of power?
- -- What if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement