How to access a table inside another table (SOLVED)

I have a Lua module that is arranged like this

return {
	player = {
		inventory = {
			items = {
				--items
			},
		}
	},

}

How would I access ‘items’ this is for a defsave save file.

So I can access inventory with

defsave.get("player", "inventory")

but I don’t know how to get a layer deeper. I think I’m being a bit stupid, but I can’t figure out what I’m doing wrong. I appreciate any help you can provide. Thanks

You should be able to just do something like defsave.get("player", "inventory").items.

I think with a normal table it is. I think this is something to do with defsave. @Pkeod do you know

I recall from back when I used to use DefSave, I was required to format my save data in a table that did not contain any other tables. This is because tables are represented as memory addresses, so you’re just saving that address, rather than the contents of the inner table. It is possible to implement a deep-copy equivalent for save data, but DefSave doesn’t do that.

Ok. Thanks. So every table has to be an individual table rather than stacked

Yes I think your right. I made it its own table and it is working now. Thanks so much.

1 Like