SHARE
    TWEET
    hoodedperson

    systemScanner.lua

    Jul 17th, 2025 (edited)
    184
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    1. local function copyTable(...)
    2. local tArgs = {...}
    3. local copy = {}
    4. for _, piece in pairs(tArgs) do
    5. if piece and type(piece) == "table" then
    6. for key, val in pairs(piece) do
    7. if type(val) == "table" then copy[key] = copyTable( copy[key] or {}, val)
    8. else copy[key] = val end
    9. end
    10. end
    11. end
    12. return copy
    13. end
    14. local ticker = peripheral.find("stockcheckingblock")
    15. local toMonitor = {"minecraft:cobblestone"}
    16. local itemLocations = {}
    17. local networkSize = ticker.inventorySize()
    18. local emptyTable = {}
    19. local timeTable = {}
    20. local iter = 0
    21. while true do
    22. iter = iter + 1
    23. timeTable[iter] = {os.epoch("utc")}
    24. for i=1, networkSize do
    25. term.clear()
    26. term.setCursorPos(1,1)
    27. print("Getting item locations")
    28. print(tostring(iter)..": "..tostring(i).."/"..tostring(networkSize))
    29. local item = ticker.itemBasicDetails(i)
    30. if itemLocations[item.id] == nil then
    31. itemLocations[item.id] = copyTable(emptyTable)
    32. end
    33. table.insert(itemLocations[item.id], i)
    34. end
    35. emptyTable[iter] = -1
    36. timeTable[iter][2] = os.epoch("utc")
    37. local serialised = textutils.serialise({
    38. itemLocations = itemLocations,
    39. timeTable = timeTable,
    40. })
    41. local h = fs.open("systemScan.lon","w+")
    42. h.write(serialised)
    43. h.close()
    44. end
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /