Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("top")
- local modem = peripheral.wrap("back")
- local chest = peripheral.wrap("industrialforegoing:black_hole_unit_tile_159")
- modem.open(1)
- local itemAliases = {
- ["projecte:item.pe_matter"] = "Red Matter",
- ["projecte:rm_furnace"] = "RM Furnace",
- ["projecte:matter_block"] = "RM Block"
- }
- local function getItemAlias(itemName)
- return itemAliases[itemName] or itemName
- end
- local function formatEMCValue(emc)
- local billion = emc / 1000000000 -- EMC değerini milyar olarak dönüştürün
- return string.format("%.2fB", billion) -- Virgülden sonra ilk 2 rakamı göstererek milyar 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
- 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