Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local time = 0
- local startemc = nil
- local storage = peripheral.wrap("back")
- local mon = peripheral.find("monitor")
- mon.w, mon.h = mon.getSize()
- -- The item you want to track and its fixed EMC value
- local tracked_item = "projecte:rm_furnace"
- local tracked_emc_value = 10059784
- local function clear()
- term.clear()
- mon.clear()
- term.setCursorPos(5, 3)
- term.setBackgroundColor(colors.blue)
- mon.setTextColor(colors.black)
- mon.setTextScale(2)
- end
- function formatTime(sec)
- return string.format("%.2d:%.2d:%.2d", sec / (60 * 60), sec / 60 % 60, sec % 60)
- end
- -- New function to format large numbers into shortened form
- function formatLargeNumber(n)
- local suffixes = {"", "K", "M", "B", "T", "Q"}
- local i = 1
- while n >= 1000 and i < #suffixes do
- n = n / 1000
- i = i + 1
- end
- return string.format("%.1f %s", n, suffixes[i])
- end
- clear()
- term.redirect(mon)
- while true do
- clear()
- local emc = 0
- local amount = 0
- -- Iterate over each item in the storage container
- for slot, item in pairs(storage.list()) do
- -- Check if the item matches the tracked item
- if item.name == tracked_item then
- amount = amount + item.count
- emc = emc + (item.count * tracked_emc_value)
- end
- end
- mon.setTextColor(colors.black)
- mon.setCursorPos(8, 1)
- mon.write("EMC Monitor")
- mon.setCursorPos(5, 3)
- mon.write("EMC: " .. formatLargeNumber(emc))
- if startemc == nil then startemc = emc end
- local gained = emc - startemc
- local emcrate = time > 0 and math.floor(gained / time) * 60 or 0
- mon.setCursorPos(5, 4)
- mon.write("EMC/m: " .. formatLargeNumber(emcrate))
- mon.setCursorPos(5, 5)
- mon.write("Time: " .. formatTime(time))
- mon.setCursorPos(5, 6)
- mon.write("Amount: " .. formatLargeNumber(amount))
- time = time + 1
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement