forked from DJYazan/Wave-Saveinstance
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveinstance.lua
More file actions
Latest commit
105 lines (90 loc) · 3.49 KB
/
Copy pathsaveinstance.lua
File metadata and controls
105 lines (90 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
localStandardOptioms= {
noscripts=false,
mode="all",
maxTimeout=10,
fileName="savedInstance.rbxlx",
customDecompiler=false,
disclude="default"
}
localfunctionescapeXml(value)
returntostring(value):gsub("&", "&"):gsub("<", "<"):gsub(">", ">"):gsub("\"", """):gsub("'", "'")
end
localfunctiongetProperties(instance)
localproperties= {}
for_, propinipairs({"Name", "ClassName", "Parent", "Archivable"}) do
localsuccess, value=pcall(function() returninstance[prop] end)
ifsuccessthenproperties[prop] =valueend
end
returnproperties
end
localfunctionserializeProperties(instance)
localproperties= {}
localprops=getProperties(instance)
forprop, valueinpairs(props) do
iftypeof(value) =="Instance" then
value=value:GetFullName()
end
value=escapeXml(tostring(value))
table.insert(properties, string.format("<%s>%s</%s>", prop, value, prop))
end
returntable.concat(properties, "\n")
end
localfunctionserializeInstance(instance, options, statusLabel)
localserialized= {}
table.insert(serialized, string.format('<Item class="%s" referent="%s">', instance.ClassName, tostring(instance:GetDebugId())))
table.insert(serialized, "<Properties>")
table.insert(serialized, serializeProperties(instance))
table.insert(serialized, "</Properties>")
for_, childinipairs(instance:GetChildren()) do
statusLabel.Text="Decompiling: " ..child:GetFullName()
wait(0.05)
ifoptions.mode=="all" or (options.mode=="scripts" andchild:IsA("Script")) then
ifnotoptions.noscriptsornotchild:IsA("Script") then
table.insert(serialized, serializeInstance(child, options, statusLabel))
end
end
end
table.insert(serialized, "</Item>")
returntable.concat(serialized, "\n")
end
localfunctioncreateStatusLabel()
localscreenGui=Instance.new("ScreenGui", game.CoreGui)
localtextLabel=Instance.new("TextLabel", screenGui)
textLabel.Size=UDim2.new(0, 400, 0, 50)
textLabel.Position=UDim2.new(0.5, -200, 0, 0)
textLabel.TextColor3=Color3.new(1, 1, 1)
textLabel.BackgroundTransparency=0.5
textLabel.BackgroundColor3=Color3.new(0, 0, 0)
textLabel.TextScaled=true
textLabel.Text="Initializing..."
returntextLabel
end
functionsaveinstance(opt)
localoptions=optorStandardOptioms
localinstances= {}
table.insert(instances, '<?xml version="1.0" encoding="utf-8"?>')
table.insert(instances, '<roblox version="4">')
localstatusLabel=createStatusLabel()
localtopLevelServices= {
game.ReplicatedStorage,
game.ReplicatedFirst,
game.StarterPlayer,
game.Workspace,
game.StarterGui,
game.StarterPack,
game.Teams,
game.Lighting
}
for_, serviceinipairs(topLevelServices) do
statusLabel.Text="Decompiling: " ..service:GetFullName()
table.insert(instances, serializeInstance(service, options, statusLabel))
end
table.insert(instances, '</roblox>')
localcontent=table.concat(instances, "\n")
localsize=#content
statusLabel.Text="File size: " ..tostring(size) .." bytes"
localfileName=options.fileNameor"savedInstance.rbxlx"
writefile(fileName, content)
print("File saved as: " ..fileName.." (Size: " ..size.." bytes)")
end
saveinstance()