Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions MInstance.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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!!
Expand Down Expand Up @@ -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)
Expand All @@ -509,6 +525,7 @@ Minstance.SerializeInstance = function(TargetInstance: Instance, SerializationSe
AnnoyingConsolePrints: boolean,
UseLegacySlowCompressor: boolean,
IncludeAttributes: boolean,
IncludeTags: boolean,
DisallowedProperties: {[string]: {[string]: any} } | nil
})

Expand All @@ -522,6 +539,7 @@ Minstance.SerializeInstance = function(TargetInstance: Instance, SerializationSe
AnnoyingConsolePrints = false,
UseLegacySlowCompressor = false,
IncludeAttributes = true,
IncludeTags = true,
DisallowedProperties = NULL
-- EXAMPLE:
-- {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -737,4 +755,4 @@ end
-- Minstance.CreateInstanceMap = CreateInstanceMap
-- Minstance.ReverseInstanceMap = ReverseInstanceMap

return Minstance
return Minstance