Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("right")
- local chest = peripheral.wrap("bottom")
- local itemAliases = {
- ["projecte:item.pe_matter"] = "Red Matter",
- ["projecte:rm_furnace"] = "RM Furnace",
- ["projecte:matter_block"] = "RM Block",
- ["projecte:item.pe_fuel"] = "Mobius Fuel"
- }
- local function getItemAlias(itemName)
- return itemAliases[itemName] or itemName
- end
- local function formatEMCValue(emc)
- local thousand = emc / 1000 -- EMC değerini bin olarak dönüştürün
- return string.format("%.2fK", thousand) -- Virgülden sonra ilk 2 rakamı göstererek bin olarak formatlayın
- end
- local function getEMCValue(itemName, itemCount)
- local emcValue = 0
- if itemName == "Red Matter" then
- emcValue = itemCount * 466944
- elseif itemName == "RM Furnace" then
- emcValue = itemCount * 10059784
- elseif itemName == "RM Block" then
- emcValue = itemCount * 1867776
- elseif itemName == "Mobius Fuel" then
- emcValue = itemCount * 2048
- end
- return emcValue
- end
- local function getItemsWithPrefix(prefix, items)
- local filteredItems = {}
- for slot, item in pairs(items) do
- local itemName = item.name
- if string.sub(itemName, 1, #prefix) == prefix then
- local alias = getItemAlias(itemName)
- local emc = getEMCValue(alias, item.count)
- table.insert(filteredItems, { name = alias, count = item.count, emc = emc })
- end
- end
- return filteredItems
- end
- while true do
- monitor.clear()
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(1, 1)
- monitor.write("Chest Contents")
- local items = chest.list()
- local filteredItems = getItemsWithPrefix("projecte:", items)
- for _, item in ipairs(filteredItems) do
- monitor.setCursorPos(1, 3)
- monitor.write(item.name .. ": " .. item.count)
- monitor.setCursorPos(1, 5)
- monitor.write("EMC: " .. formatEMCValue(item.emc))
- end
- sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement