Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local pim = component.pim
- local inventory = component.inventory_controller
- local fs = require("filesystem")
- local function getItemInfo(slot)
- local item = inventory.getStackInSlot(1, slot)
- if item then
- return {
- itemLabel = item.label or "Unknown Item",
- itemName = item.name or "Unknown Name",
- itemDamage = item.damage or 0
- }
- else
- return nil
- end
- end
- local function saveToFile(filename, data)
- local file = io.open(filename, "w")
- if file then
- file:write(data)
- file:close()
- else
- print("Error: Unable to open file for writing.")
- end
- end
- local function scanInventory()
- local results = {}
- for slot = 1, 27 do
- local itemInfo = getItemInfo(slot)
- if itemInfo then
- local resultLine = string.format(
- "{\n itemLabel = \"%s\",\n itemName = \"%s\",\n itemDamage = %d\n},",
- itemInfo.itemLabel,
- itemInfo.itemName,
- itemInfo.itemDamage
- )
- table.insert(results, resultLine)
- end
- end
- saveToFile("tet", table.concat(results, "\n"))
- end
- event.listen("player_on", function()
- print("Player detected on PIM. Scanning inventory...")
- scanInventory()
- end)
- print("Waiting for player on PIM...")
- while true do
- event.pull()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement