diff --git a/MInstance.luau b/MInstance.luau index a3882ac..d64baec 100644 --- a/MInstance.luau +++ b/MInstance.luau @@ -151,7 +151,7 @@ local CreateAddressFromDescendantToParent = function(Descendant, Parent) return Address end -CreateInstanceMap = function(TargetInstance, IncludeDescendants, PrintProcess, MainInstanceReference, IncludeAttributes, DisallowedProperties, PropertyCompression) +CreateInstanceMap = function(TargetInstance, IncludeDescendants, PrintProcess, MainInstanceReference, IncludeAttributes, IncludeTags, DisallowedProperties, PropertyCompression) local ClassName = __index(TargetInstance, "ClassName") local Map = { @@ -255,7 +255,16 @@ CreateInstanceMap = function(TargetInstance, IncludeDescendants, PrintProcess, M break end end + + if IncludeTags then + local Tags = TargetInstance:GetTags() + for _ in pairs(Tags) do + Map.T = Tags -- the key of this dict was previously Tags, shortened for compression + break + end + end + -- if PrintProcess then -- ThrowToConsole(`Mapping Instance "{TargetInstance:GetFullName()}" ({ClassName})...`) -- end @@ -269,7 +278,7 @@ CreateInstanceMap = function(TargetInstance, IncludeDescendants, PrintProcess, M local MicroOptimizationReference = Map.K for _, Child in ipairs(Children) do - local NewInstanceMap = CreateInstanceMap(Child, true, PrintProcess, MainInstanceReference, IncludeAttributes, DisallowedProperties, PropertyCompression) + local NewInstanceMap = CreateInstanceMap(Child, true, PrintProcess, MainInstanceReference, IncludeAttributes, IncludeTags, DisallowedProperties, PropertyCompression) if NewInstanceMap then table_insert(MicroOptimizationReference, NewInstanceMap) @@ -348,6 +357,7 @@ ReverseInstanceMap = function(Map, ParentOfInstance, DeserializeMeshPartsProperl local Properties = Map.P local Children = Map.K local Attributes = Map.A + local Tags = Map.T local CallbackTable = Map.Callbacks local InternalPropertyHooks = EMPTY_TABLE local UseInternalPropertyHooks = false -- CPU CYCLES MUST NOT GO TO WASTE!! @@ -492,6 +502,12 @@ ReverseInstanceMap = function(Map, ParentOfInstance, DeserializeMeshPartsProperl end end + if Tags then + for _, Name in pairs(Tags) do + MainInstance:AddTag(Name) + end + end + if Children then for _, Child in ipairs(Children) do ReverseInstanceMap(Child, MainInstance, DeserializeMeshPartsProperly, MainMapReference, TemporaryCacheTable, PropertyCompression) @@ -509,6 +525,7 @@ Minstance.SerializeInstance = function(TargetInstance: Instance, SerializationSe AnnoyingConsolePrints: boolean, UseLegacySlowCompressor: boolean, IncludeAttributes: boolean, + IncludeTags: boolean, DisallowedProperties: {[string]: {[string]: any} } | nil }) @@ -522,6 +539,7 @@ Minstance.SerializeInstance = function(TargetInstance: Instance, SerializationSe AnnoyingConsolePrints = false, UseLegacySlowCompressor = false, IncludeAttributes = true, + IncludeTags = true, DisallowedProperties = NULL -- EXAMPLE: -- { @@ -562,7 +580,7 @@ Minstance.SerializeInstance = function(TargetInstance: Instance, SerializationSe PropertyCompressionCount = 0 end - local MainMap = CreateInstanceMap(TargetInstance, Settings.IncludeDescendants, Settings.AnnoyingConsolePrints, TargetInstance, Settings.IncludeAttributes, Settings.DisallowedProperties) + local MainMap = CreateInstanceMap(TargetInstance, Settings.IncludeDescendants, Settings.AnnoyingConsolePrints, TargetInstance, Settings.IncludeAttributes, Settings.IncludeTags, Settings.DisallowedProperties) if PropertyCompressionCount > 0 then PropertyCompressionCount = 0 @@ -737,4 +755,4 @@ end -- Minstance.CreateInstanceMap = CreateInstanceMap -- Minstance.ReverseInstanceMap = ReverseInstanceMap -return Minstance +return Minstance \ No newline at end of file