Closed Scyfren closed 4 years ago
This is backwards incompatible behavior, it doesn't do this now intentionally in the case of something like setting an inventory table, and wanting to change the default items later, or changing the schema on how items are handled.
I may be open to this as a different function though.
Currently,
DataStore:GetTableAsync(default)
only patches missing keys on the first "layer" of the DataStore value. If the value itself contains tables, it will not sync with the respective default value.e.g. If the value looks like this:
and
default
looks like this:Owned.Default = true
will not be added to the DataStore value.Solution:
TableUtil.sync(tbl, default) -> bool
Adds missing keys totbl
fromdefault
. Iftbl
contains table values, TableUtil.sync will be used on those table values. Returns whethertbl
was changed at all.When
DataStore:GetTableAsync(default)
is called, it should now sync the DataStore value withdefault
, where if the value itself contains a table, it will sync that table with the respective table value indefault
.