Advertisement
Grexxity

Untitled

Oct 19th, 2024 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. local time = 0
  2. local startemc = nil
  3. local storage = peripheral.wrap("back")
  4. local mon = peripheral.find("monitor")
  5. mon.w, mon.h = mon.getSize()
  6.  
  7. -- The item you want to track and its fixed EMC value
  8. local tracked_item = "projecte:rm_furnace"
  9. local tracked_emc_value = 10059784
  10.  
  11. local function clear()
  12. term.clear()
  13. mon.clear()
  14. term.setCursorPos(5, 3)
  15. term.setBackgroundColor(colors.blue)
  16. mon.setTextColor(colors.black)
  17. mon.setTextScale(2)
  18. end
  19.  
  20. function formatTime(sec)
  21. return string.format("%.2d:%.2d:%.2d", sec / (60 * 60), sec / 60 % 60, sec % 60)
  22. end
  23.  
  24. -- New function to format large numbers into shortened form
  25. function formatLargeNumber(n)
  26. local suffixes = {"", "K", "M", "B", "T", "Q"}
  27. local i = 1
  28. while n >= 1000 and i < #suffixes do
  29. n = n / 1000
  30. i = i + 1
  31. end
  32. return string.format("%.1f %s", n, suffixes[i])
  33. end
  34.  
  35. clear()
  36. term.redirect(mon)
  37.  
  38. while true do
  39. clear()
  40.  
  41. local emc = 0
  42. local amount = 0
  43.  
  44. -- Iterate over each item in the storage container
  45. for slot, item in pairs(storage.list()) do
  46. -- Check if the item matches the tracked item
  47. if item.name == tracked_item then
  48. amount = amount + item.count
  49. emc = emc + (item.count * tracked_emc_value)
  50. end
  51. end
  52.  
  53. mon.setTextColor(colors.black)
  54. mon.setCursorPos(8, 1)
  55. mon.write("EMC Monitor")
  56.  
  57. mon.setCursorPos(5, 3)
  58. mon.write("EMC: " .. formatLargeNumber(emc))
  59. if startemc == nil then startemc = emc end
  60.  
  61. local gained = emc - startemc
  62. local emcrate = time > 0 and math.floor(gained / time) * 60 or 0
  63. mon.setCursorPos(5, 4)
  64. mon.write("EMC/m: " .. formatLargeNumber(emcrate))
  65.  
  66. mon.setCursorPos(5, 5)
  67. mon.write("Time: " .. formatTime(time))
  68.  
  69. mon.setCursorPos(5, 6)
  70. mon.write("Amount: " .. formatLargeNumber(amount))
  71.  
  72. time = time + 1
  73.  
  74. sleep(1)
  75. end
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement