You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marked as feature request because I only intended to duplicate the data (key/values) of a table when I implemented the first version of table.copy. Metatables are an after-thought. Copying that (recursively) to the new table shouldn't be too complicated.
Metatables are an after-thought. Copying that (recursively) to the new table shouldn't be too complicated.
I don't think the metatable should generally be copied, both for performance and correctness reasons (think vector.is being false for a copied vector because you copied the vector "class" as well). It should just be restored instead.
Short term I think we should just add a boolean param defaulting to false that indicates whether to preserve metatables, probably with a notice that we plan to make this the default eventually (though technically the fact that metatables are stripped is not something we guarantee in our docs).
Longer term, we can provide a recursive core.strip_metatables for those who want that, but e.g. vectors losing their metatables through copying is not a useful default. Cases where you want to strip metatables are much rarer.
Luanti version
Operating system and version
Windows 11
CPU model
No response
GPU model
No response
Active renderer
No response
Summary
The title says it all I guess:
table.copy
doesn't keep metatables into copied tables.Steps to reproduce
The text was updated successfully, but these errors were encountered: