Advertisement
colhaydutu

emc

Sep 28th, 2023 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. local monitor = peripheral.wrap("right")
  2. local chest = peripheral.wrap("bottom")
  3.  
  4. local itemAliases = {
  5. ["projecte:item.pe_matter"] = "Red Matter",
  6. ["projecte:rm_furnace"] = "RM Furnace",
  7. ["projecte:matter_block"] = "RM Block",
  8. ["projecte:item.pe_fuel"] = "Mobius Fuel"
  9. }
  10.  
  11. local function getItemAlias(itemName)
  12. return itemAliases[itemName] or itemName
  13. end
  14.  
  15. local function formatEMCValue(emc)
  16. local thousand = emc / 1000 -- EMC değerini bin olarak dönüştürün
  17. return string.format("%.2fK", thousand) -- Virgülden sonra ilk 2 rakamı göstererek bin olarak formatlayın
  18. end
  19.  
  20. local function getEMCValue(itemName, itemCount)
  21. local emcValue = 0
  22.  
  23. if itemName == "Red Matter" then
  24. emcValue = itemCount * 466944
  25. elseif itemName == "RM Furnace" then
  26. emcValue = itemCount * 10059784
  27. elseif itemName == "RM Block" then
  28. emcValue = itemCount * 1867776
  29. elseif itemName == "Mobius Fuel" then
  30. emcValue = itemCount * 2048
  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