Advertisement
colhaydutu

Untitled

Sep 28th, 2023 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. local monitor = peripheral.wrap("top")
  2. local modem = peripheral.wrap("back")
  3.  
  4. local chest = peripheral.wrap("industrialforegoing:black_hole_unit_tile_159")
  5.  
  6. modem.open(1)
  7. local itemAliases = {
  8. ["projecte:item.pe_matter"] = "Red Matter",
  9. ["projecte:rm_furnace"] = "RM Furnace",
  10. ["projecte:matter_block"] = "RM Block"
  11. }
  12.  
  13. local function getItemAlias(itemName)
  14. return itemAliases[itemName] or itemName
  15. end
  16.  
  17. local function formatEMCValue(emc)
  18. local billion = emc / 1000000000 -- EMC değerini milyar olarak dönüştürün
  19. return string.format("%.2fB", billion) -- Virgülden sonra ilk 2 rakamı göstererek milyar olarak formatlayın
  20. end
  21.  
  22. local function getEMCValue(itemName, itemCount)
  23. local emcValue = 0
  24.  
  25. if itemName == "Red Matter" then
  26. emcValue = itemCount * 466944
  27. elseif itemName == "RM Furnace" then
  28. emcValue = itemCount * 10059784
  29. elseif itemName == "RM Block" then
  30. emcValue = itemCount * 1867776
  31. end
  32.  
  33. return emcValue
  34. end
  35.  
  36. local function getItemsWithPrefix(prefix, items)
  37. local filteredItems = {}
  38.  
  39. for slot, item in pairs(items) do
  40. local itemName = item.name
  41. if string.sub(itemName, 1, #prefix) == prefix then
  42. local alias = getItemAlias(itemName)
  43. local emc = getEMCValue(alias, item.count)
  44. table.insert(filteredItems, { name = alias, count = item.count, emc = emc })
  45. end
  46. end
  47.  
  48. return filteredItems
  49. end
  50.  
  51. while true do
  52. monitor.clear()
  53. monitor.setBackgroundColor(colors.black)
  54. monitor.setTextColor(colors.red)
  55. monitor.setCursorPos(1, 1)
  56. monitor.write("Chest Contents")
  57.  
  58. local items = chest.list()
  59. local filteredItems = getItemsWithPrefix("projecte:", items)
  60.  
  61.  
  62. for _, item in ipairs(filteredItems) do
  63. monitor.setCursorPos(1, 3)
  64. monitor.write(item.name .. ": " .. item.count)
  65. monitor.setCursorPos(1, 5)
  66. monitor.write("EMC: " .. formatEMCValue(item.emc))
  67.  
  68. end
  69.  
  70. sleep(3)
  71. end
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement