Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function copyTable(...)
- local tArgs = {...}
- local copy = {}
- for _, piece in pairs(tArgs) do
- if piece and type(piece) == "table" then
- for key, val in pairs(piece) do
- if type(val) == "table" then copy[key] = copyTable( copy[key] or {}, val)
- else copy[key] = val end
- end
- end
- end
- return copy
- end
- local ticker = peripheral.find("stockcheckingblock")
- local toMonitor = {"minecraft:cobblestone"}
- local itemLocations = {}
- local networkSize = ticker.inventorySize()
- local emptyTable = {}
- local timeTable = {}
- local iter = 0
- while true do
- iter = iter + 1
- timeTable[iter] = {os.epoch("utc")}
- for i=1, networkSize do
- term.clear()
- term.setCursorPos(1,1)
- print("Getting item locations")
- print(tostring(iter)..": "..tostring(i).."/"..tostring(networkSize))
- local item = ticker.itemBasicDetails(i)
- if itemLocations[item.id] == nil then
- itemLocations[item.id] = copyTable(emptyTable)
- end
- table.insert(itemLocations[item.id], i)
- end
- emptyTable[iter] = -1
- timeTable[iter][2] = os.epoch("utc")
- local serialised = textutils.serialise({
- itemLocations = itemLocations,
- timeTable = timeTable,
- })
- local h = fs.open("systemScan.lon","w+")
- h.write(serialised)
- h.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment