-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_specific_instance.lua
More file actions
530 lines (518 loc) · 17.6 KB
/
save_specific_instance.lua
File metadata and controls
530 lines (518 loc) · 17.6 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
if _G.ToSave == nil then
_G.ToSave = game.Players.LocalPlayer.Character -- Welcome loadstring haters, put the path of what you want to save here
end
--[[
If you're seeing this, you're probably not using the loadstring!
It's probably better to use this version instead:
---------------------------
_G.ToSave = game.Players.LocalPlayer.Character -- Put the path of the thing you want to save here
loadstring(game:HttpGet(('https://raw.githubusercontent.com/Aidez/MISC/main/save_specific_instance'),true))()
---------------------------
MASSIVE CREDIT TO https://v3rmillion.net/showthread.php?tid=1032423
MOST OF THIS SCRIPT IS REPURPOSED CODE FROM THEIR SCRIPT
--]]
local newline = tostring("\n")
local Xml = {
start = '<roblox xmlns:xmime="https://www.w3.org/2005/05/xmlmime" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.roblox.com/roblox.xsd" version="4">'..newline..'<Meta name="ExplicitAutoJoints">true</Meta>'..newline..'<External>null</External>'..newline..'<External>nil</External>',
finish = '</roblox>'
}
local Property = {}
function Property:convert(p1, p2, p3, p4)
local p4_gsub = {
double = "number",
int = "number",
int32 = "number",
int64 = "number",
float = "number",
float32 = "number",
float64 = "number",
bool = "boolean",
CreatorType = "EnumItem",
MeshType = "EnumItem",
CameraType = "EnumItem",
RenderFidelity = "EnumItem",
Color3uint8 = "Fault",
SystemAddress = "Fault",
Camera = "Ref",
BasePart = "Ref",
Workspace = "Ref",
Instance = "Ref",
Player = "Ref",
GuiObject = "Ref",
LocalizationTable = "Ref"
}
local Convert_Types = {
number = function()
local p3 = p3[1]
local isInteger = p3 % 1 == 0
local ConversionType = isInteger and "int" or "float"
local Conversion_Format = [[<%s name="%s">%s</%s>]]
return string.format(Conversion_Format, ConversionType, p2, p3, ConversionType)
end,
NumberRange = function()
local p3 = p3[1]
local Conversion_Format = [[<NumberRange name="%s">%s</NumberRange>]]
return string.format(Conversion_Format, p2, p3.Min.." "..p3.Max)
end,
NumberSequence = function()
local p3 = p3[1]
local Conversion_Format = [[<NumberSequence name="%s">%s</NumberSequence>]]
local ConvertedArray = {}
for _, Keypoints in next, p3.Keypoints do
--table.insert(ConvertedArray, unpack(Keypoints))
table.insert(ConvertedArray, Keypoints.Envelope)
table.insert(ConvertedArray, Keypoints.Time)
table.insert(ConvertedArray, Keypoints.Value)
end
return string.format(Conversion_Format, p2, tostring(unpack(ConvertedArray)))
end,
ColorSequence = function()
local p3 = p3[1]
local Conversion_Format = [[<ColorSequence name="%s">%s</ColorSequence>]]
local ConvertedArray = {}
for _, Keypoints in next, p3.Keypoints do
--table.insert(ConvertedArray, unpack(Keypoints))
table.insert(ConvertedArray, Keypoints.Time)
table.insert(ConvertedArray, Keypoints.Value)
end
return string.format(Conversion_Format, p2, tostring(unpack(ConvertedArray)))
end,
string = function()
local p3 = p3[1]
local Conversion_Format
if string.find(p3,"rbxassetid") or string.find(p3,"roblox.com/asset") then
Conversion_Format = [[<Content name="%s"><url>%s</url></Content>]]
else
Conversion_Format = [[<string name="%s">%s</string>]]
end
return string.format(Conversion_Format, p2, p3)
end,
BinaryString = function()
local p3 = p3[1]
local Conversion_Format = '<BinaryString name="%s"><![CDATA[%s]]></BinaryString>'
local Raw_Conversion_Format = '<BinaryString name="%s">%s</BinaryString>'
local isNilValue = tostring(p3) == "nil"
return string.format(isNilValue and Raw_Conversion_Format or Conversion_Format, p2, isNilValue and "" or p3)
end,
ProtectedString = function()
local p3 = p3[1]
local Conversion_Format = '<ProtectedString name="%s"><![CDATA[%s]]></ProtectedString>'
return string.format(Conversion_Format, p2, p3)
end,
Content = function()
local p3 = p3[1]
local Conversion_Format = p4 ~= nil and [[<Content name="%s"><url>%s</url></Content>]] or [[<Content name="%s"><null></null></Content>]]
return string.format(Conversion_Format, p2, p3)
end,
Ray = function()
local p3 = p3[1]
local Conversion_Format = [[<Ray name="%s">
<origin>
<X>%s</X>
<Y>%s</Y>
<Z>%s</Z>
</origin>
<direction>
<X>%s</X>
<Y>%s</Y>
<Z>%s</Z>
</direction>
</Ray>]]
return string.format(Conversion_Format, p2, p3.Origin.X, p3.Origin.Y, p3.Origin.Z, p3.Direction.X, p3.Direction.Y, p3.Direction.Z)
end,
boolean = function()
local p3 = p3[1]
local Conversion_Format = [[<bool name="%s">%s</bool>]]
return string.format(Conversion_Format, p2, tostring(p3))
end,
EnumItem = function()
local p3 = p3[1]
local Conversion_Format = [[<token name="%s">%s</token>]]
return string.format(Conversion_Format, p2, p3.Value)
end,
CFrame = function()
local p3 = p3[1]
local Conversion_Format = [[<CoordinateFrame name="%s">
<X>%s</X>
<Y>%s</Y>
<Z>%s</Z>
<R00>%s</R00>
<R01>%s</R01>
<R02>%s</R02>
<R10>%s</R10>
<R11>%s</R11>
<R12>%s</R12>
<R20>%s</R20>
<R21>%s</R21>
<R22>%s</R22>
</CoordinateFrame>]]
return string.format(Conversion_Format, p2, p3.X, p3.Y, p3.Z, p3.RightVector.X, p3.RightVector.Y, p3.RightVector.Z, p3.UpVector.X, p3.UpVector.Y, p3.UpVector.Z, p3.LookVector.X, p3.LookVector.Y, p3.LookVector.Z)
end,
Vector3 = function()
local p3 = p3[1]
local Conversion_Format = [[<Vector3 name="%s">
<X>%s</X>
<Y>%s</Y>
<Z>%s</Z>
</Vector3>]]
return string.format(Conversion_Format, p2, p3.X, p3.Y, p3.Z)
end,
Vector2 = function()
local p3 = p3[1]
local Conversion_Format = [[<Vector2 name="%s">
<X>%s</X>
<Y>%s</Y>
</Vector2>]]
return string.format(Conversion_Format, p2, p3.X, p3.Y)
end,
UDim = function()
local p3 = p3[1]
local Conversion_Format = [[<UDim name="%s">
<S>%s</S>
<O>%s</O>
</UDim>]]
return string.format(Conversion_Format, p2, p3.Scale, p3.Offset)
end,
UDim2 = function()
local p3 = p3[1]
local Conversion_Format = [[<UDim2 name="%s">
<XS>%s</XS>
<XO>%s</XO>
<YS>%s</YS>
<YO>%s</YO>
</UDim2>]]
return string.format(Conversion_Format, p2, p3.X.Scale, p3.X.Offset, p3.Y.Scale, p3.Y.Offset)
end,
Rect = function()
local p3 = p3[1]
local Conversion_Format = [[<Rect2D name="%s">
<min>
<X>%s</X>
<Y>%s</Y>
</min>
<max>
<X>%s</X>
<Y>%s</Y>
</max>
</Rect2D>]]
return string.format(Conversion_Format, p2, p3.Min.X, p3.Min.Y, p3.Max.X, p3.Max.Y)
end,
Color3 = function()
local p3 = p3[1]
local Conversion_Format = [[<Color3 name="%s">
<R>%s</R>
<G>%s</G>
<B>%s</B>
</Color3>]]
return string.format(Conversion_Format, p2, p3.R, p3.G, p3.B)
end,
PhysicalProperties = function()
local Conversion_Format = [[<PhysicalProperties name="%s">
<CustomPhysics>false</CustomPhysics>
</PhysicalProperties>]]
return string.format(Conversion_Format, p2)
end,
Axes = function()
local Conversion_Format = [[<Axes name="%s">
<axes>7</axes>
</Axes>]]
return string.format(Conversion_Format, p2)
end,
Ref = function()
local Conversion_Format = [[<Ref name="%s">null</Ref>]]
return string.format(Conversion_Format, p2)
end,
Fault = function()
return '<!--Property "'..p2..'" was not saved as it might affect inserting in Studio.-->'
end,
Faces = function()
return "<!--We are not saving Faces type properties! This is literally useless, lol.-->"
end,
Region3int16 = function()
return "<!--We are not saving Region3int16 type properties! This is literally useless, lol.-->"
end,
Vector3int16 = function()
return "<!--We are not saving Vector3int16 type properties! This is literally useless, lol.-->"
end,
Vector2int16 = function()
return "<!--We are not saving Vector2int16 type properties! This is literally useless, lol.-->"
end,
BrickColor = function()
return "<!--We are not saving BrickColor type properties! This might hurt Color3 / Color3uint8 properties.-->"
end
}
p4 = p4_gsub[p4] and p4_gsub[p4] or p4
if Convert_Types[p4] then
return Convert_Types[p4]()
else
return "<!--Couldn't load Property '"..p2.."' with type '"..p4.."'-->"
end
end
function Property:get(p1, p2, Value)
local SpecialProperties = {
CustomPhysicalProperties =
{
function()
return PhysicalProperties.new(.7,.3,.5,1,1)
end,
{},
"PhysicalProperties"
},
Source =
{
decompile,
{
p1
},
"ProtectedString"
},
ChildData =
{
readbinarystring,
{
p1,
"ChildData"
},
"BinaryString"
},
PhysicsData =
{
readbinarystring,
{
p1,
"PhysicsData"
},
"BinaryString"
},
MeshData =
{
readbinarystring,
{
p1,
"MeshData"
},
"BinaryString"
},
SmoothGrid =
{
readbinarystring,
{
p1,
"SmoothGrid"
},
"BinaryString"
},
PhysicsGrid =
{
readbinarystring,
{
p1,
"PhysicsGrid"
},
"BinaryString"
},
MaterialColors =
{
readbinarystring,
{
p1,
"MaterialColors"
},
"BinaryString"
},
Tags =
{
readbinarystring,
{
p1,
"Tags"
},
"BinaryString"
},
AttributesReplicate =
{
readbinarystring,
{
p1,
"AttributesReplicate"
},
"BinaryString"
},
AttributesSerialize =
{
readbinarystring,
{
p1,
"AttributesSerialize"
},
"BinaryString"
},
RobloxLocked =
{
checkrbxlocked,
{
p1
},
"boolean"
},
siz =
{
gethiddenproperty,
{
p1,
"Size"
},
"Vector3"
},
shap =
{
gethiddenproperty,
{
p1,
"Shape"
},
"EnumItem"
}
}
local SpecialData = SpecialProperties[p2]
if SpecialData then
local f = SpecialData[1]
if f then
local r1, r2 = f(unpack(SpecialData[2]))
return self:convert(p1, p2, {r1, r2}, SpecialData[3])
end
end
local ValueType = "string"
if Value ~= nil then
ValueType = typeof(Value)
elseif Value == nil then
ValueType = Api.Dump.Properties[p1.ClassName][p2]
end
if type(ValueType) ~= "string" then
ValueType = "string"
Value = ""
end
return self:convert(p1, p2, {Value}, ValueType)
end
local Class = {}
function Class:new(p1)
local Referent = "RBX"
for i = 1, 32 do
local Random = math.random(36)
Referent ..= string.sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", Random, Random)
end
return string.format('<Item class="%s" referent="%s">', p1, Referent), Referent
end
function Class:properties(p1, p2)
local Properties = getproperties(p2)
for Prop, Value in next, Properties do
p1 ..= Property:get(p2, Prop, Value)..newline
end
return p1
end
function Class:finish()
return '</Item>'
end
ParseItem = function(p1,p2)
local D = ""
local A, B = Class:new(p1.ClassName)
D ..= A..newline
D ..= [[<Properties>]]..newline
D = Class:properties(D, p1)
D ..= [[</Properties>]]..newline
D ..= "<!--"..B.."-->"..newline
D ..= Class:finish()..newline
local Comment = "<!--"..B.."-->"
return D,B,Comment
end
writeinstance = function(p1, p2)
local Descendants = p1:GetDescendants()
game.StarterGui:SetCore("SendNotification", {
Title = 'STARTED';
Text = "Saving your selected instance. \n("..tostring(#Descendants).." DESCENDANTS)";
Icon = "rbxassetid://2541869220";
Duration = 7;
})
print()
local Instances = {}
for i,v in pairs(Descendants) do
if i%50 == 0 then
task.wait()
end
if not string.find(v.ClassName,"Script") then
local XML,TAG,COMMENT = ParseItem(v,p2)
local depth = #string.split(v:GetFullName(),".")
if not Instances[depth] then
Instances[depth] = {}
end
local Data = {
["object"] = v;
["parent"] = v.Parent;
["tag"] = TAG;
["xml"] = XML;
["comment"] = COMMENT;
}
table.insert(Instances[depth],Data)
end
end
local D = Xml.start..newline
local MAINXML,MAINTAG,MAINCOMMENT = ParseItem(p1,p2)
D ..= MAINXML..newline
local HighestDepth = 0
local LowestDepth = math.huge
for i,v in pairs(Instances) do
if i > HighestDepth then
HighestDepth = i
end
if i < LowestDepth then
LowestDepth = i
end
end
for index = LowestDepth,HighestDepth do
for i,v in pairs(Instances[index]) do
if index == LowestDepth then
D = string.gsub(D,"<!%-%-"..MAINTAG.."%-%->",newline..v.xml..newline..MAINCOMMENT..newline)
else
--for index2 = LowestDepth,index do
for x,y in pairs(Instances[index-1]) do
if x%50 == 0 then
task.wait()
end
if v.object.Parent == y.object then
local ToSet = string.gsub(v.xml,"%%","BIGBONER")
D = string.gsub(D,"<!%-%-"..y.tag.."%-%->",newline..ToSet..newline..y.comment..newline)
end
end
--end
end
end
end
D ..= [[<SharedStrings>]]..newline
D ..= [[</SharedStrings>]]..newline
D ..= Xml.finish
D = string.gsub(D,"BIGBONER","%%")
-- local C = MAINTAG.." ("..tostring(p1)..")."..p2
local C = p1:GetFullName().."."..p2
writefile(C, D)
return C
end
local Success, Saved_As = pcall(writeinstance, _G.ToSave, "rbxmx")
if Success then
game.StarterGui:SetCore("SendNotification", {
Title = 'SUCCESS';
Text = "Instance "..tostring(_G.ToSave).." was saved to your workspace folder.";
Icon = "rbxassetid://2541869220";
Duration = 7;
})
else
game.StarterGui:SetCore("SendNotification", {
Title = "ERROR";
Text = Saved_As;
Icon = "rbxassetid://2541869220";
Duration = 7;
})
end
--[[
MASSIVE CREDIT TO https://v3rmillion.net/showthread.php?tid=1032423
MOST OF THIS SCRIPT IS REPURPOSED CODE FROM THEIR SCRIPT
--]]