This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CaptiveCreeper's profile picture

Figuring out the indexes of Open Peripherals "Stacks"

Started by CaptiveCreeper, 05 August 2015 - 02:19 AM
CaptiveCreeper #1
Posted 05 August 2015 - 04:19 AM
I am trying to figure out all the indexes for inventory "stacks" so i tried the code
for i,j inpairs(info) do
print(i .. "  " .. j)
end
with info being the stack from a inventory and it threw a error "attempt to concentrate string and table" how would I get to the indexes after that point? Any help would be appreciated.
KingofGamesYami #2
Posted 05 August 2015 - 04:24 AM
Well, j is obviously a table. So maybe we should serialize it.



for i, j in pairs( info ) do
  print( i .. ": " .. textutils.serialize( j )
end

But, if that's too much for the screen, we can save it to a file:


local f = fs.open( "infodump", "w" )
for i, j in pairs( info ) do
  f.writeLine( i .. ":" .. textutils.serialize( j ) )
end
f.close()
CaptiveCreeper #3
Posted 05 August 2015 - 10:08 PM
Thank you very much that worked perfectly.