How to print table's value without key?

If I had a table with multiple inventory slots;

local inventory = {
	[1] = {
		['WoodLog'] = {
			Name = 'Wood Log';
			ItemDescription = 'Probably came from a tree';
			ImageId = 0000000000;
			Amount = 1;
			StackLimit = 2;
		}
	};
	[2] = {};
	[3] = {};
	[4] = {};
	[5] = {};
	[6] = {};
	[7] = {};
	[8] = {};
	[9] = {};
}

Is there any way I can print Slot 1’s ImageId without using this;

print(inventory[1].WoodLog.ImageId)

I tried using the script below but it doesn’t seem to work

print(next(inventory[1]).ImageId)

Well yeah and it is quite simple,

local t = {[1] = {
 ["Woodlog"] = {
     ImageId = 100
     }
}}

local function GetValueFromIndex(Index) 
    for i,v in pairs(t) do
           if v[Index] then
                for key,value in pairs(v) do
                        return key, value
                 end
            end
      end
end

print(GetValueFromIndex("Woodlog")) 
1 Like