local args = { ... }

if args[1] == 'dump' or args[1] == nil then
    f = fs.open('/inv.txt','w')
    for i=1,16 do
        if tx.state.inv[i] ~= nil then
            t = tx.state.inv[i].item_type
            if t == nil then
                t = 'nil'
            elseif type(t) == 'table' then
                t = table.concat(t,'|')
            end
        
            s = i..': t='..t..' c='..tx.state.inv[i].count..' s='..tx.state.inv[i].space
            f.writeLine(s)
            if tx.state.inv[i].count > 0 then
                print(s)
            end
        end
    end
    f.close()
elseif args[1] == 'reset' then
    tx.state.inv = {}
elseif args[1] == 'assert' then
    slot = tonumber(args[2])
    i = 3
    item_type = ''
    while args[i] ~= nil do
        item_type = item_type..args[i]..' '
        i = i + 1
    end
    
    -- possible strip quotes and spaces
    item_type = string.sub(item_type, 1, #item_type-1)
    
    tx.assert_item_type(slot, item_type, true)
else
	print( "Usage: inv [dump|check|reset|assert]" )
	return 
end
