matter icon indicating copy to clipboard operation
matter copied to clipboard

Allow components to store any datatype

Open memorycode opened this issue 1 year ago • 7 comments

This PR adds support for non-table components. Calling Components.Model(model) will return a table that has a special marker on it that tells the World it should be unwrapped on insertion. I explicitly chose this strategy because it means that we can do not need to store this table in archetypes.

Unfortunately, we still need to store Components.Model(model) initially inside of a table because we need a way to get the component ID and Luau does not have tuples.

memorycode avatar Nov 16 '24 16:11 memorycode

Could you also update the description of the PR with a brief description of how this PR achieves what it says in the title in case anyone looks back at it later?

LastTalon avatar Nov 18 '24 22:11 LastTalon

Could you also update the description of the PR with a brief description of how this PR achieves what it says in the title in case anyone looks back at it later?

Updated the description.

memorycode avatar Nov 20 '24 14:11 memorycode

@LastTalon, I started updating the docs but I'm still not sure what to call everything. As it stands, the docs for Component say that it returns a ComponentInstance, but this is not true anymore.

memorycode avatar Nov 20 '24 17:11 memorycode

but this is not true anymore.

How so? It seems to me like it does.

LastTalon avatar Nov 21 '24 16:11 LastTalon

but this is not true anymore.

How so? It seems to me like it does.

Well, it can return a ComponentInstance, if we want to consider that a ComponentInstance. But I don't think we should consider it a ComponentInstance because we don't want people interacting with it in the same way they interact with table components.

memorycode avatar Nov 23 '24 18:11 memorycode

This doesn't seem complicated to me. We clearly just have two types of component instance now. What else would have you it return?

It seems to me it returns a ComponentInstance still. It's just that that type is now a union of TableComponentInstance | ValueComponentInstance.

LastTalon avatar Nov 26 '24 17:11 LastTalon

This doesn't seem complicated to me. We clearly just have two types of component instance now. What else would have you it return?

It seems to me it returns a ComponentInstance still. It's just that that type is now a union of TableComponentInstance | ValueComponentInstance.

Just updated the docs to what I believe they could potentially look like. Curious if this is what you had in mind.

memorycode avatar Dec 12 '24 18:12 memorycode