w3vu2m81e912ce7m

e

Sep 27th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.37 KB | None | 0 0
  1.  
  2. local assert, type, typeof, rawset, getmetatable, tostring = assert, type, typeof, rawset, getmetatable, tostring
  3. local print, warn, pack, unpack, next = print, warn, table.pack, unpack, next
  4.  
  5. local IsSharedFrozen, SharedSize = SharedTable.isFrozen, SharedTable.size
  6. local bufftostring, fromstring, readu8 = buffer.tostring, buffer.fromstring, buffer.readu8
  7. local isfrozen, concat = table.isfrozen, table.concat
  8. local info = debug.info
  9.  
  10. local DefaultMethods = {}
  11. local Methods = setmetatable({}, {__index = DefaultMethods})
  12. local Class = {
  13. Methods = Methods,
  14. _tostringUnsupported = false,
  15. _Serializeinf = false,
  16. __VERSION = "1.0"
  17. }
  18.  
  19. local Keywords = {
  20. ["local"] = "\"local\"",
  21. ["function"] = "\"function\"",
  22. -- ["type"] = "\"type\"",
  23. -- ["typeof"] = "\"typeof\"",
  24. -- ["export"] = "\"export\"",
  25. -- ["continue"] = "\"continue\"",
  26. ["and"] = "\"and\"",
  27. ["break"] = "\"break\"",
  28. ["not"] = "\"not\"",
  29. ["or"] = "\"or\"",
  30. ["else"] = "\"else\"",
  31. ["elseif"] = "\"elseif\"",
  32. ["if"] = "\"if\"",
  33. ["then"] = "\"then\"",
  34. ["until"] = "\"until\"",
  35. ["repeat"] = "\"repeat\"",
  36. ["while"] = "\"while\"",
  37. ["do"] = "\"do\"",
  38. ["for"] = "\"for\"",
  39. ["in"] = "\"in\"",
  40. ["end"] = "\"end\"",
  41. ["return"] = "\"return\"",
  42. ["true"] = "\"true\"",
  43. ["false"] = "\"false\"",
  44. ["nil"] = "\"nil\""
  45. }
  46.  
  47. local weakkeys = {__mode = "k"}
  48.  
  49. local islclosure = islclosure or function<func>(Function : func)
  50. return info(Function, "l") ~= -1
  51. end
  52.  
  53. local DefaultVectors, DefaultCFrames = {}, {} do
  54. local function ExtractTypes<Library>(DataTypeLibrary : Library, Path : string, DataType : string, Storage : {[any] : string})
  55. for i,v in next, DataTypeLibrary do
  56. if typeof(v) == DataType and not Storage[v] and type(i) == "string" and not Keywords[i] or not i:match("[a-Z_][a-Z_0-9]") then
  57. Storage[v] = Path.."."..i
  58. end
  59. end
  60. end
  61.  
  62. ExtractTypes(vector, "vector", "Vector3", DefaultVectors)
  63. ExtractTypes(Vector3, "Vector3", "Vector3", DefaultVectors)
  64. ExtractTypes(CFrame, "CFrame", "CFrame", DefaultCFrames)
  65.  
  66. Class.DefaultTypes = {
  67. Vector3 = DefaultVectors,
  68. CFrame = DefaultCFrames,
  69. }
  70. end
  71.  
  72. local function Serialize<Type>(DataStructure : Type, format : boolean?, indents : string, CyclicList : {[{[any] : any?}] : boolean | nil}?, InComment : boolean?)
  73. local DataHandler = Methods[typeof(DataStructure)]
  74.  
  75. return if DataHandler then DataHandler(DataStructure, format, indents, CyclicList, InComment) else "nil --["..(if InComment then "" else "=").."[ Unsupported Data Type | "..typeof(DataStructure)..(if not Class._tostringUnsupported then "" else " | "..tostring(DataStructure)).." ]"..(if not InComment then "" else "=").."]"
  76. end
  77.  
  78. local function ValidateSharedTableIndex(Index : string)
  79. local IsKeyword = if type(Index) == "number" then Index else Keywords[Index]
  80.  
  81. if not IsKeyword then
  82. if Index ~= "" then
  83. local IndexBuffer = fromstring(Index)
  84. local FirstByte = readu8(IndexBuffer, 0)
  85.  
  86. if FirstByte >= 97 and FirstByte <= 122 or FirstByte >= 65 and FirstByte <= 90 or FirstByte == 95 then
  87. for i = 1, #Index-1 do
  88. local Byte = readu8(IndexBuffer, i)
  89.  
  90. if not ((Byte >= 97 and Byte <= 122) or (Byte >= 65 and Byte <= 90) or Byte == 95 or (Byte >= 48 and Byte <= 57)) then
  91. return "["..Methods.string(Index).."] = "
  92. end
  93. end
  94.  
  95. return Index.." = "
  96. end
  97.  
  98. return "["..Methods.string(Index).."] = "
  99. end
  100.  
  101. return "[\"\"] = "
  102. end
  103.  
  104. return "["..IsKeyword.."] = "
  105. end
  106.  
  107. local function ValidateIndex(Index : any)
  108. local IndexType = type(Index)
  109. local IsNumber = IndexType == "number"
  110.  
  111. if IsNumber or IndexType == "string" then
  112. local IsKeyword = if IsNumber then Index else Keywords[Index]
  113.  
  114. if not IsKeyword then
  115. if Index ~= "" then
  116. local IndexBuffer = fromstring(Index)
  117. local FirstByte = readu8(IndexBuffer, 0)
  118.  
  119. if FirstByte >= 97 and FirstByte <= 122 or FirstByte >= 65 and FirstByte <= 90 or FirstByte == 95 then
  120. for i = 1, #Index-1 do
  121. local Byte = readu8(IndexBuffer, i)
  122.  
  123. if not ((Byte >= 97 and Byte <= 122) or (Byte >= 65 and Byte <= 90) or Byte == 95 or (Byte >= 48 and Byte <= 57)) then
  124. return "["..Methods.string(Index).."] = "
  125. end
  126. end
  127.  
  128. return Index.." = "
  129. end
  130.  
  131. return "["..Methods.string(Index).."] = "
  132. end
  133.  
  134. return "[\"\"] = "
  135. end
  136.  
  137. return "["..IsKeyword.."] = "
  138. end
  139.  
  140. return "["..(if IndexType ~= "table" then Serialize(Index, false, "") else "\"<Table> (table: "..(if getmetatable(Index) == nil then tostring(Index):sub(8) else "@metatable")..")\"").."] = "
  141. end
  142.  
  143. function DefaultMethods.Axes(Axes : Axes)
  144. return "Axes.new("..concat({
  145. if Axes.X then "Enum.Axis.X" else nil,
  146. if Axes.Y then "Enum.Axis.Y" else nil,
  147. if Axes.Z then "Enum.Axis.Z" else nil
  148. },", ")..")"
  149. end
  150.  
  151. function DefaultMethods.BrickColor(Color : BrickColor)
  152. return "BrickColor.new("..Color.Number..")"
  153. end
  154.  
  155. function DefaultMethods.CFrame(CFrame : CFrame)
  156. local Generation = DefaultCFrames[CFrame]
  157.  
  158. if not Generation then
  159. local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = CFrame:GetComponents()
  160. local SerializeNumber = Methods.number
  161.  
  162. return "CFrame.new("..SerializeNumber(x)..", "..SerializeNumber(y)..", "..SerializeNumber(z)..", "..SerializeNumber(R00)..", "..SerializeNumber(R01)..", "..SerializeNumber(R02)..", "..SerializeNumber(R10)..", "..SerializeNumber(R11)..", "..SerializeNumber(R12)..", "..SerializeNumber(R20)..", "..SerializeNumber(R21)..", "..SerializeNumber(R22)..")"
  163. end
  164.  
  165. return Generation
  166. end
  167.  
  168. do
  169. local DefaultCatalogSearchParams = CatalogSearchParams.new()
  170. function DefaultMethods.CatalogSearchParams(Params : CatalogSearchParams, format : boolean?, indents : string)
  171. if DefaultCatalogSearchParams ~= Params then
  172. local formatspace = if format then "\n"..indents else " "
  173. local SerializeString = Methods.string
  174. local SearchKeyword = Params.SearchKeyword
  175. local MinPrice = Params.MinPrice
  176. local MaxPrice = Params.MaxPrice
  177. local SortType = Params.SortType
  178. local SortAggregation = Params.SortAggregation
  179. local CategoryFilter = Params.CategoryFilter
  180. local SalesTypeFilter = Params.SalesTypeFilter
  181. local BundleTypes = Params.BundleTypes
  182. local AssetTypes = Params.AssetTypes
  183. local CreatorName = Params.CreatorName
  184. local CreatorType = Params.CreatorType
  185. local CreatorId = Params.CreatorId
  186. local Limit = Params.Limit
  187.  
  188. return "(function(Param : CatalogSearchParams)"..formatspace..(if SearchKeyword ~= "" then "\tParam.SearchKeyword = "..SerializeString(SearchKeyword)..formatspace else "")..(if MinPrice ~= 0 then "\tParam.MinPrice = "..MinPrice..formatspace else "")..(if MaxPrice ~= 2147483647 then "\tParam.MaxPrice = "..MaxPrice..formatspace else "")..(if SortType ~= Enum.CatalogSortType.Relevance then "\tParam.SortType = Enum.CatalogSortType."..SortType.Name..formatspace else "")..(if SortAggregation ~= Enum.CatalogSortAggregation.AllTime then "\tParam.SortAggregation = Enum.CatalogSortAggregation."..SortAggregation.Name..formatspace else "")..(if CategoryFilter ~= Enum.CatalogCategoryFilter.None then "\tParam.CategoryFilter = Enum.CatalogCategoryFilter."..CategoryFilter.Name..formatspace else "")..(if SalesTypeFilter ~= Enum.SalesTypeFilter.All then "\tParam.SalesTypeFilter = Enum.SalesTypeFilter."..SalesTypeFilter.Name..formatspace else "")..(if #BundleTypes > 0 then "\tParam.BundleTypes = "..Methods.table(BundleTypes, false, "")..formatspace else "")..(if #AssetTypes > 0 then "\tParam.AssetTypes = "..Methods.table(AssetTypes, false, "")..formatspace else "")..(if Params.IncludeOffSale then "\tParams.IncludeOffSale = true"..formatspace else "")..(if CreatorName ~= "" then "\tParams.CreatorName = "..SerializeString(CreatorName)..formatspace else "")..(if CreatorType ~= Enum.CreatorTypeFilter.All then "\tParam.CreatorType = Enum.CreatorTypeFilter."..CreatorType.Name..formatspace else "")..(if CreatorId ~= 0 then "\tParams.CreatorId = "..CreatorId..formatspace else "")..(if Limit ~= 30 then "\tParams.Limit = "..Limit..formatspace else "").."\treturn Params"..formatspace.."end)(CatalogSearchParams.new())"
  189. end
  190.  
  191. return "CatalogSearchParams.new()"
  192. end
  193. end
  194.  
  195. function DefaultMethods.Color3(Color : Color3)
  196. local SerializeNumber = Methods.number
  197.  
  198. return "Color3.new("..SerializeNumber(Color.R)..", "..SerializeNumber(Color.G)..", "..SerializeNumber(Color.B)..")"
  199. end
  200.  
  201. function DefaultMethods.ColorSequence(Sequence : ColorSequence)
  202. local SerializeColorSequenceKeypoint = Methods.ColorSequenceKeypoint
  203. local Keypoints = Sequence.Keypoints
  204. local Size = #Keypoints
  205. local Serialized = ""
  206.  
  207. for i = 1, Size-1 do
  208. Serialized ..= SerializeColorSequenceKeypoint(Keypoints[i])..", "
  209. end
  210.  
  211. return "ColorSequence.new({"..Serialized..SerializeColorSequenceKeypoint(Keypoints[Size]).."})"
  212. end
  213.  
  214. function DefaultMethods.ColorSequenceKeypoint(KeyPoint : ColorSequenceKeypoint)
  215. return "ColorSequenceKeypoint.new("..Methods.number(KeyPoint.Time)..", "..Methods.Color3(KeyPoint.Value)..")"
  216. end
  217.  
  218. function DefaultMethods.Content(content : Content)
  219. local Uri = content.Uri
  220.  
  221. return if Uri then "Content.fromUri("..Uri..")" else "Content.none"
  222. end
  223.  
  224. function DefaultMethods.DateTime(Date : DateTime)
  225. return "DateTime.fromUnixTimestampMillis("..Date.UnixTimestampMillis..")"
  226. end
  227.  
  228. function DefaultMethods.DockWidgetPluginGuiInfo(Dock : DockWidgetPluginGuiInfo)
  229. local ArgumentFunction = tostring(Dock):gmatch(":([%w%-]+)")
  230.  
  231. return "DockWidgetPluginGuiInfo.new(Enum.InitialDockState."..ArgumentFunction()..", "..(if ArgumentFunction() == "1" then "true" else "false")..", "..(if ArgumentFunction() == "1" then "true" else "false")..", "..ArgumentFunction()..", "..ArgumentFunction()..", "..ArgumentFunction()..", "..ArgumentFunction()..")"
  232. end
  233.  
  234. function DefaultMethods.Enum(Enum : Enum)
  235. return "Enums."..tostring(Enum)
  236. end
  237.  
  238. do
  239. local Enums = {}
  240.  
  241. for i,v in Enum:GetEnums() do
  242. Enums[v] = "Enum."..tostring(v)
  243. end
  244.  
  245. function DefaultMethods.EnumItem(Item : EnumItem)
  246. return Enums[Item.EnumType].."."..Item.Name
  247. end
  248. end
  249.  
  250. function DefaultMethods.Enums()
  251. return "Enums"
  252. end
  253.  
  254. function DefaultMethods.Faces(Faces : Faces)
  255. return "Faces.new("..concat({
  256. if Faces.Top then "Enum.NormalId.Top" else nil,
  257. if Faces.Bottom then "Enum.NormalId.Bottom" else nil,
  258. if Faces.Left then "Enum.NormalId.Left" else nil,
  259. if Faces.Right then "Enum.NormalId.Right" else nil,
  260. if Faces.Back then "Enum.NormalId.Back" else nil,
  261. if Faces.Front then "Enum.NormalId.Front" else nil,
  262. }, ", ")..")"
  263. end
  264.  
  265. function DefaultMethods.FloatCurveKey(CurveKey : FloatCurveKey)
  266. local SerializeNumber = Methods.number
  267.  
  268. return "FloatCurveKey.new("..SerializeNumber(CurveKey.Time)..", "..SerializeNumber(CurveKey.Value)..", Enum.KeyInterpolationMode."..CurveKey.Interpolation.Name..")"
  269. end
  270.  
  271. function DefaultMethods.Font(Font : Font)
  272. return "Font.new("..Methods.string(Font.Family)..", Enum.FontWeight."..Font.Weight.Name..", Enum.FontStyle."..Font.Style.Name..")"
  273. end
  274.  
  275. do
  276. local Players = game:GetService("Players")
  277. local FindService = game.FindService
  278.  
  279. local Services = {
  280. Workspace = "workspace",
  281. Lighting = "game.lighting",
  282. GlobalSettings = "settings()",
  283. Stats = "stats()",
  284. UserSettings = "UserSettings()",
  285. PluginManagerInterface = "PluginManager()",
  286. DebuggerManager = "DebuggerManager()"
  287. }
  288.  
  289. if game:GetService("RunService"):IsClient() then
  290. local LocalPlayer = Players.LocalPlayer
  291.  
  292. if not LocalPlayer then
  293. Players:GetPropertyChangedSignal("LocalPlayer"):Once(function()
  294. LocalPlayer = Players.LocalPlayer
  295. end)
  296. end
  297.  
  298. function DefaultMethods.Instance(obj : Instance)
  299. local ObjectParent = obj.Parent
  300. local ObjectClassName = obj.ClassName
  301.  
  302. if ObjectParent then
  303. local ObjectName = Methods.string(obj.Name)
  304.  
  305. if ObjectClassName ~= "Model" and ObjectClassName ~= "Player" then
  306. local IsService, Output = pcall(FindService, game, ObjectClassName)
  307.  
  308. return if not (IsService and Output) then Methods.Instance(ObjectParent)..":WaitForChild("..ObjectName..")" else Services[ObjectClassName] or "game:GetService(\""..ObjectClassName.."\")"
  309. elseif ObjectClassName == "Model" then
  310. local Player = Players:GetPlayerFromCharacter(obj)
  311.  
  312. return if not Player then Methods.Instance(ObjectParent)..":WaitForChild("..ObjectName..")" else "game:GetService(\"Players\")".. (if Player == LocalPlayer then ".LocalPlayer.Character" else ":WaitForChild("..ObjectName..").Character")
  313. end
  314.  
  315. return "game:GetService(\"Players\")".. (if obj == LocalPlayer then ".LocalPlayer" else ":WaitForChild("..ObjectName..")")
  316. end
  317.  
  318. return if ObjectClassName == "DataModel" then "game" else "Instance.new(\""..ObjectClassName.."\", nil)"
  319. end
  320. else
  321. function DefaultMethods.Instance(obj : Instance)
  322. local ObjectParent = obj.Parent
  323. local ObjectClassName = obj.ClassName
  324.  
  325. if ObjectParent then
  326. local ObjectName = Methods.string(obj.Name)
  327.  
  328. if ObjectClassName ~= "Model" and ObjectClassName ~= "Player" then
  329. local IsService, Output = pcall(FindService, game, ObjectClassName)
  330.  
  331. return if not (IsService and Output) then Methods.Instance(ObjectParent)..":WaitForChild("..ObjectName..")" else Services[ObjectClassName] or "game:GetService(\""..ObjectClassName.."\")"
  332. elseif ObjectClassName == "Model" then
  333. local Player = Players:GetPlayerFromCharacter(obj)
  334.  
  335. return if not Player then Methods.Instance(ObjectParent)..":WaitForChild("..ObjectName..")" else "game:GetService(\"Players\"):WaitForChild("..ObjectName..").Character"
  336. end
  337.  
  338. return "game:GetService(\"Players\"):WaitForChild("..ObjectName..")"
  339. end
  340.  
  341. return if ObjectClassName == "DataModel" then "game" else "Instance.new(\""..ObjectClassName.."\", nil)"
  342. end
  343. end
  344.  
  345. Class.Services = Services
  346. end
  347.  
  348. function DefaultMethods.NumberRange(Range : NumberRange)
  349. local SerializeNumber = Methods.number
  350.  
  351. return "NumberRange.new("..SerializeNumber(Range.Min)..", "..SerializeNumber(Range.Max)..")"
  352. end
  353.  
  354. function DefaultMethods.NumberSequence(Sequence : NumberSequence)
  355. local SerializeNumberSequenceKeypoint = Methods.NumberSequenceKeypoint
  356. local Keypoints = Sequence.Keypoints
  357. local Size = #Keypoints
  358. local Serialized = ""
  359.  
  360. for i = 1, Size-1 do
  361. Serialized ..= SerializeNumberSequenceKeypoint(Keypoints[i])..", "
  362. end
  363.  
  364. return "NumberSequence.new({"..Serialized..SerializeNumberSequenceKeypoint(Keypoints[Size]).."})"
  365. end
  366.  
  367. do
  368. local DefaultOverlapParams = OverlapParams.new()
  369. function DefaultMethods.OverlapParams(Params : OverlapParams, format : boolean?, indents : string)
  370. if DefaultOverlapParams ~= Params then
  371. local formatspace = format and "\n"..indents or " "
  372. local FilterDescendantsInstances = Params.FilterDescendantsInstances
  373. local FilterType = Params.FilterType
  374. local CollisionGroup = Params.CollisionGroup
  375.  
  376. return "(function(Param : OverlapParams)"..formatspace..(if #FilterDescendantsInstances > 0 then "\tParam.FilterDescendantsInstances = "..Methods.table(FilterDescendantsInstances, false, "")..formatspace else "")..(if FilterType ~= Enum.RaycastFilterType.Exclude then "\tParam.FilterType = Enum.RaycastFilterType."..FilterType.Name..formatspace else "")..(if CollisionGroup ~= "Default" then "\tParam.CollisionGroup = "..Methods.string(CollisionGroup)..formatspace else "")..(if Params.RespectCanCollide then "\tParam.RespectCanCollide = true"..formatspace else "")..(if Params.BruteForceAllSlow then "\tParam.BruteForceAllSlow = true"..formatspace else "").."\treturn Params"..formatspace.."end)(OverlapParams.new())"
  377. end
  378.  
  379. return "OverlapParams.new()"
  380. end
  381. end
  382.  
  383. function DefaultMethods.NumberSequenceKeypoint(Keypoint : NumberSequenceKeypoint)
  384. local SerializeNumber = Methods.number
  385.  
  386. return "NumberSequenceKeypoint.new("..SerializeNumber(Keypoint.Time)..", "..SerializeNumber(Keypoint.Value)..", "..SerializeNumber(Keypoint.Envelope)..")"
  387. end
  388.  
  389. function DefaultMethods.PathWaypoint(Waypoint : PathWaypoint)
  390. return "PathWaypoint.new("..Methods.Vector3(Waypoint.Position)..", Enum.PathWaypointAction."..Waypoint.Action.Name..", "..Methods.string(Waypoint.Label)..")"
  391. end
  392.  
  393. do
  394. local function nanToString(num : number)
  395. return if num == num then num else "0/0"
  396. end
  397.  
  398. function DefaultMethods.PhysicalProperties(Properties : PhysicalProperties)
  399. return "PhysicalProperties.new("..(nanToString(Properties.Density))..", "..nanToString(Properties.Friction)..", "..nanToString(Properties.Elasticity)..", "..nanToString(Properties.FrictionWeight)..", "..nanToString(Properties.ElasticityWeight)..")"
  400. end
  401. end
  402.  
  403. function DefaultMethods.RBXScriptConnection(Connection : RBXScriptConnection, _, _, _, InComment : boolean?)
  404. local CommentSeperator = if not InComment then "" else "="
  405.  
  406. return "(nil --["..CommentSeperator.."[ RBXScriptConnection | IsConnected: "..(if Connection.Connected then "true" else "false").." ]"..CommentSeperator.."])" -- Can't support this
  407. end
  408.  
  409. do
  410. local Signals = {
  411. GraphicsQualityChangeRequest = "game.GraphicsQualityChangeRequest",
  412. AllowedGearTypeChanged = "game.AllowedGearTypeChanged",
  413. ScreenshotSavedToAlbum = "game.ScreenshotSavedToAlbum",
  414. UniverseMetadataLoaded = "game.UniverseMetadataLoaded",
  415. ScreenshotReady = "game.ScreenshotReady",
  416. ServiceRemoving = "game.ServiceRemoving",
  417. ServiceAdded = "game.ServiceAdded",
  418. ItemChanged = "game.ItemChanged",
  419. CloseLate = "game.CloseLate",
  420. Loaded = "game.Loaded",
  421. Close = "game.Close",
  422.  
  423. RobloxGuiFocusedChanged = "game:GetService(\"RunService\").RobloxGuiFocusedChanged",
  424. PostSimulation = "game:GetService(\"RunService\").PostSimulation",
  425. RenderStepped = "game:GetService(\"RunService\").RenderStepped",
  426. PreSimulation = "game:GetService(\"RunService\").PreSimulation",
  427. PreAnimation = "game:GetService(\"RunService\").PreAnimation",
  428. PreRender = "game:GetService(\"RunService\").PreRender",
  429. Heartbeat = "game:GetService(\"RunService\").Heartbeat",
  430. Stepped = "game:GetService(\"RunService\").Stepped"
  431. }
  432.  
  433. function DefaultMethods.RBXScriptSignal(Signal : RBXScriptSignal, _, _, _, InComment : boolean?)
  434. local CommentSeperator = if not InComment then "" else "="
  435. local SignalName = tostring(Signal):match("Signal ([A-z]+)")
  436.  
  437. return Signals[SignalName] or "(nil --["..CommentSeperator.."[ RBXScriptSignal | "..SignalName.." is not supported ]"..CommentSeperator.."])"
  438. end
  439.  
  440. Class.Signals = Signals
  441. end
  442.  
  443. function DefaultMethods.Random(_, _, _, _, InComment : boolean?)
  444. local CommentSeperator = if not InComment then "" else "="
  445.  
  446. return "Random.new(--["..CommentSeperator.."[ <Seed> ]"..CommentSeperator.."])"
  447. end
  448.  
  449. function DefaultMethods.Ray(Ray : Ray)
  450. local SerializeVector3 = Methods.Vector3
  451.  
  452. return "Ray.new("..SerializeVector3(Ray.Origin)..", "..SerializeVector3(Ray.Direction)..")"
  453. end
  454.  
  455. do
  456. local DefaultRaycastParams = RaycastParams.new()
  457. function DefaultMethods.RaycastParams(Params : RaycastParams, format : boolean?, indents : string)
  458. if DefaultRaycastParams ~= Params then
  459. local formatspace = format and "\n"..indents or " "
  460. local FilterDescendantsInstances = Params.FilterDescendantsInstances
  461. local FilterType = Params.FilterType
  462. local CollisionGroup = Params.CollisionGroup
  463.  
  464. return "(function(Param : RaycastParams)"..formatspace..(if #FilterDescendantsInstances > 0 then "\tParam.FilterDescendantsInstances = "..Methods.table(FilterDescendantsInstances, false, "")..formatspace else "")..(if FilterType ~= Enum.RaycastFilterType.Exclude then "\tParam.FilterType = Enum.RaycastFilterType."..FilterType.Name..formatspace else "")..(if Params.IgnoreWater then "\tParam.IgnoreWater = true"..formatspace else "")..(if CollisionGroup ~= "Default" then "\tParam.CollisionGroup = "..Methods.string(CollisionGroup)..formatspace else "")..(if Params.RespectCanCollide then "\tParam.RespectCanCollide = true"..formatspace else "")..(if Params.BruteForceAllSlow then "\tParam.BruteForceAllSlow = true"..formatspace else "").."\treturn Params"..formatspace.."end)(RaycastParams.new())"
  465. end
  466.  
  467. return "RaycastParams.new()"
  468. end
  469. end
  470. function DefaultMethods.Rect(Rect : Rect)
  471. local SerializeVector2 = Methods.Vector2
  472. return "Rect.new("..SerializeVector2(Rect.Min)..", "..SerializeVector2(Rect.Max)..")"
  473. end
  474. function DefaultMethods.Region3(Region : Region3)
  475. local SerializeVector3 = Methods.Vector3
  476. local Center = Region.CFrame.Position
  477. local Size = Region.Size/2
  478.  
  479. return "Region3.new("..SerializeVector3(Center - Size)..", "..SerializeVector3(Center + Size)..")"
  480. end
  481. function DefaultMethods.Region3int16(Region : Region3int16)
  482. local SerializeVector3int16 = Methods.Vector3int16
  483.  
  484. return "Region3int16.new("..SerializeVector3int16(Region.Min)..", "..SerializeVector3int16(Region.Max)..")"
  485. end
  486. function DefaultMethods.RotationCurveKey(Curve : RotationCurveKey)
  487. return "RotationCurveKey.new("..Methods.number(Curve.Time)..", "..Methods.CFrame(Curve.Value)..", Enum.KeyInterpolationMode."..Curve.Interpolation.Name..")"
  488. end
  489. function DefaultMethods.SharedTable(Shared : SharedTable, format : boolean?, indents : string, _, InComment : boolean?)
  490. local isreadonly = IsSharedFrozen(Shared)
  491. if SharedSize(Shared) ~= 0 then
  492. local stackindent = indents..(if format then "\t" else "")
  493. local CurrentIndex = 1
  494. local Serialized = {}
  495. for i,v in Shared do
  496. Serialized[CurrentIndex] = (if CurrentIndex ~= i then ValidateSharedTableIndex(i) else "")..Serialize(v, format, stackindent, nil, InComment)
  497. CurrentIndex += 1
  498. end
  499. local formatspace = if format then "\n" else ""
  500. local Contents = formatspace..stackindent..concat(Serialized, (if format then ",\n" else ", ")..stackindent)..formatspace..indents
  501. return if not isreadonly then "SharedTable.new({"..Contents.."})" else "SharedTable.cloneAndFreeze(SharedTable.new({"..Contents.."}))"
  502. end
  503. return if not isreadonly then "SharedTable.new()" else "SharedTable.cloneAndFreeze(SharedTable.new())"
  504. end
  505. function DefaultMethods.TweenInfo(Info : TweenInfo)
  506. return "TweenInfo.new("..Methods.number(Info.Time)..", Enum.EasingStyle."..Info.EasingStyle.Name..", Enum.EasingDirection."..Info.EasingDirection.Name..", "..Info.RepeatCount..", "..(if Info.Reverses then "true" else "false")..", "..Methods.number(Info.DelayTime)..")"
  507. end
  508. function DefaultMethods.UDim(UDim : UDim)
  509. return "UDim.new("..Methods.number(UDim.Scale)..", "..UDim.Offset..")"
  510. end
  511. function DefaultMethods.UDim2(UDim2 : UDim2)
  512. local SerializeNumber = Methods.number
  513. local Width = UDim2.X
  514. local Height = UDim2.Y
  515.  
  516. return "UDim2.new("..SerializeNumber(Width.Scale)..", "..Width.Offset..", "..SerializeNumber(Height.Scale)..", "..Height.Offset..")"
  517. end
  518. function DefaultMethods.Vector2(Vector : Vector2)
  519. local SerializeNumber = Methods.number
  520.  
  521. return "Vector2.new("..SerializeNumber(Vector.X)..", "..SerializeNumber(Vector.Y)..")"
  522. end
  523. function DefaultMethods.Vector2int16(Vector : Vector2int16)
  524. return "Vector2int16.new("..Vector.X..", "..Vector.Y..")"
  525. end
  526. function DefaultMethods.Vector3(Vector : Vector3)
  527. local SerializeNumber = Methods.number
  528.  
  529. return DefaultVectors[Vector] or "vector.create("..SerializeNumber(Vector.X)..", "..SerializeNumber(Vector.Y)..", "..SerializeNumber(Vector.Z)..")" -- vector library is more efficent/accurate
  530. end
  531. function DefaultMethods.Vector3int16(Vector : Vector3int16)
  532. return "Vector3int16.new("..Vector.X..", "..Vector.Y..", "..Vector.Z..")"
  533. end
  534. function DefaultMethods.boolean(bool : boolean)
  535. return if bool then "true" else "false"
  536. end
  537. function DefaultMethods.buffer(buff : buffer)
  538. return "buffer.fromstring("..Methods.string(bufftostring(buff))..")"
  539. end
  540. do
  541. local GlobalFunctions = {} do
  542. local getrenv = getrenv or (function()
  543. local env = {
  544. bit32 = bit32,
  545. buffer = buffer,
  546. coroutine = coroutine,
  547. debug = debug,
  548. math = math,
  549. os = os,
  550. string = string,
  551. table = table,
  552. utf8 = utf8,
  553. Content = Content,
  554. Axes = Axes,
  555. AdReward = AdReward,
  556. BrickColor = BrickColor,
  557. CatalogSearchParams = CatalogSearchParams,
  558. CFrame = CFrame,
  559. Color3 = Color3,
  560. ColorSequence = ColorSequence,
  561. ColorSequenceKeypoint = ColorSequenceKeypoint,
  562. DateTime = DateTime,
  563. DockWidgetPluginGuiInfo = DockWidgetPluginGuiInfo,
  564. Faces = Faces,
  565. FloatCurveKey = FloatCurveKey,
  566. Font = Font,
  567. Instance = Instance,
  568. NumberRange = NumberRange,
  569. NumberSequence = NumberSequence,
  570. NumberSequenceKeypoint = NumberSequenceKeypoint,
  571. OverlapParams = OverlapParams,
  572. PathWaypoint = PathWaypoint,
  573. PhysicalProperties = PhysicalProperties,
  574. Random = Random,
  575. Ray = Ray,
  576. RaycastParams = RaycastParams,
  577. Rect = Rect,
  578. Region3 = Region3,
  579. Region3int16 = Region3int16,
  580. RotationCurveKey = RotationCurveKey,
  581. SharedTable = SharedTable,
  582. task = task,
  583. TweenInfo = TweenInfo,
  584. UDim = UDim,
  585. UDim2 = UDim2,
  586. Vector2 = Vector2,
  587. Vector2int16 = Vector2int16,
  588. Vector3 = Vector3,
  589. vector = vector,
  590. Vector3int16 = Vector3int16,
  591. CellId = CellId,
  592. PluginDrag = PluginDrag,
  593. SecurityCapabilities = SecurityCapabilities,
  594. assert = assert,
  595. error = error,
  596. getfenv = getfenv,
  597. getmetatable = getmetatable,
  598. ipairs = ipairs,
  599. loadstring = loadstring,
  600. newproxy = newproxy,
  601. next = next,
  602. pairs = pairs,
  603. pcall = pcall,
  604. print = print,
  605. rawequal = rawequal,
  606. rawget = rawget,
  607. rawlen = rawlen,
  608. rawset = rawset,
  609. select = select,
  610. setfenv = setfenv,
  611. setmetatable = setmetatable,
  612. tonumber = tonumber,
  613. tostring = tostring,
  614. unpack = unpack,
  615. xpcall = xpcall,
  616. collectgarbage = collectgarbage,
  617. delay = delay,
  618. gcinfo = gcinfo,
  619. PluginManager = PluginManager,
  620. DebuggerManager = DebuggerManager,
  621. require = require,
  622. settings = settings,
  623. spawn = spawn,
  624. tick = tick,
  625. time = time,
  626. UserSettings = UserSettings,
  627. wait = wait,
  628. warn = warn,
  629. Delay = Delay,
  630. ElapsedTime = ElapsedTime,
  631. elapsedTime = elapsedTime,
  632. printidentity = printidentity,
  633. Spawn = Spawn,
  634. Stats = Stats,
  635. stats = stats,
  636. Version = Version,
  637. version = version,
  638. Wait = Wait
  639. }
  640. return function()
  641. return env
  642. end
  643. end)()
  644. local Visited = setmetatable({}, weakkeys)
  645. for i,v in getrenv() do
  646. local ElementType = type(i) == "string" and type(v)
  647. if ElementType then
  648. if ElementType == "table" then
  649. local function LoadLibrary(Path : string, tbl : {[string] : any})
  650. if not Visited[tbl] then
  651. Visited[tbl] = true
  652. for i,v in next, tbl do
  653. local Type = type(i) == "string" and not Keywords[i] and i:match("[A-z_][A-z_0-9]") and type(v)
  654. local NewPath = Type and (Type == "function" or Type == "table") and Path.."."..i
  655. if NewPath then
  656. if Type == "function" then
  657. GlobalFunctions[v] = NewPath
  658. else
  659. LoadLibrary(NewPath, v)
  660. end
  661. end
  662. end
  663. Visited[tbl] = nil
  664. end
  665. end
  666. LoadLibrary(i, v)
  667. table.clear(Visited)
  668. elseif ElementType == "function" then
  669. GlobalFunctions[v] = i
  670. end
  671. end
  672. end
  673. Class.GlobalFunctions = GlobalFunctions
  674. end
  675. DefaultMethods["function"] = function(Function : (...any?) -> ...any?, format : boolean?, indents : string, _, InComment : boolean?)
  676. local IsGlobal = GlobalFunctions[Function]
  677. if not IsGlobal then
  678. if format then
  679. local SerializeString = Methods.string
  680. local CommentSeperator = if not InComment then "" else "="
  681. local tempindents = indents.."\t\t\t"
  682. local newlineindent = ",\n"..tempindents
  683. local source, line, name, numparams, vargs = info(Function, "slna")
  684. local lclosure = line ~= -1
  685. return (if lclosure then "" else "coroutine.wrap(").."function()\n\t"..indents.."--["..CommentSeperator.."[\n\t\t"..indents.."info = {\n"..tempindents.."source = "..SerializeString(source)..newlineindent.."line = "..line..newlineindent.."what = "..(if lclosure then "\"Lua\"" else "\"C\"")..newlineindent.."name = "..SerializeString(name)..newlineindent.."numparams = "..numparams..newlineindent.."vargs = "..(if vargs then "true" else "false")..newlineindent.."function = "..tostring(Function).."\n\t\t"..indents.."}\n\t"..indents.."]"..CommentSeperator.."]\n"..indents.."end"..(if lclosure then "" else ")")
  686. end
  687. return if islclosure(Function) then "function() end" else "coroutine.wrap(function() end)"
  688. end
  689. return IsGlobal
  690. end
  691. end
  692. function DefaultMethods.table(tbl : {[any] : any}, format : boolean?, indents : string, CyclicList : {[{[any] : any?}] : boolean | nil}?, InComment : boolean?)
  693. if not CyclicList then
  694. CyclicList = setmetatable({}, weakkeys)
  695. end
  696. if not CyclicList[tbl] then
  697. local isreadonly = isfrozen(tbl)
  698. local Index, Value = next(tbl)
  699. if Index ~= nil then
  700. local Indents = indents..(if format then "\t" else "")
  701. local Ending = (if format then ",\n" else ", ")
  702. local formatspace = if format then "\n" else ""
  703. local Generation = "{"..formatspace
  704. local CurrentIndex = 1
  705. CyclicList[tbl] = true
  706. repeat
  707. Generation ..= Indents..(if CurrentIndex ~= Index then ValidateIndex(Index) else "")..Serialize(Value, format, Indents, CyclicList, InComment)
  708. Index, Value = next(tbl, Index)
  709. Generation ..= if Index ~= nil then Ending else formatspace..indents.."}"
  710. CurrentIndex += 1
  711. until Index == nil
  712. CyclicList[tbl] = nil
  713. return if not isreadonly then Generation else "table.freeze("..Generation..")"
  714. end
  715. return if not isreadonly then "{}" else "table.freeze({})"
  716. else
  717. return "*** cycle table reference detected ***"
  718. end
  719. end
  720. DefaultMethods["nil"] = function()
  721. return "nil"
  722. end
  723. function DefaultMethods.number(num : number)
  724. return if num < 1/0 and num > -1/0 then tostring(num) elseif num == 1/0 then (if Class._Serializeinf then "math.huge" else "1/0") elseif num == num then (if Class._Serializeinf then "-math.huge" else "-1/0") else "0/0"
  725. end
  726. do
  727. local ByteList = {
  728. ["\a"] = "\\a",
  729. ["\b"] = "\\b",
  730. ["\t"] = "\\t",
  731. ["\n"] = "\\n",
  732. ["\v"] = "\\v",
  733. ["\f"] = "\\f",
  734. ["\r"] = "\\r",
  735. ["\""] = "\\\"",
  736. ["\\"] = "\\\\"
  737. }
  738. for i = 0, 255 do
  739. local Character = (i < 32 or i > 126) and string.char(i)
  740.  
  741. if Character and not ByteList[Character] then
  742. ByteList[Character] = ("\\%03d"):format(i)
  743. end
  744. end
  745. function DefaultMethods.string(RawString : string)
  746. return "\""..RawString:gsub("[\0-\31\34\92\127-\255]", ByteList).."\""
  747. end
  748. end
  749. function DefaultMethods.thread(thread : thread)
  750. return "coroutine.create(function() end)"
  751. end
  752. function DefaultMethods.userdata(userdata : any)
  753. return getmetatable(userdata) ~= nil and "newproxy(true)" or "newproxy(false)"
  754. end
  755. do
  756. local SecurityCapabilityEnums = Enum.SecurityCapability:GetEnumItems()
  757. function DefaultMethods.SecurityCapabilities(Capabilities : SecurityCapabilities, format : boolean?, _, _, InComment : boolean?)
  758. local ContainedCapabilities = {}
  759. local CurrentIndex = 1
  760. for i,v in SecurityCapabilityEnums do
  761. if Capabilities:Contains(v) then
  762. ContainedCapabilities[CurrentIndex] = "Enum.SecurityCapability."..v.Name
  763. CurrentIndex += 1
  764. end
  765. end
  766. return "SecurityCapabilities.new("..concat(ContainedCapabilities, ", ")..")"
  767. end
  768. end
  769. function DefaultMethods.PluginDrag(Drag : PluginDrag)
  770. local SerializeString = Methods.string
  771. return "PluginDrag.new("..SerializeString(Drag.Sender)..", "..SerializeString(Drag.MimeType)..", "..SerializeString(Drag.Data)..", "..SerializeString(Drag.MouseIcon)..", "..SerializeString(Drag.DragIcon)..", "..Methods.Vector2(Drag.HotSpot)..")"
  772. end
  773. function DefaultMethods.CellId(_, _, _, _, InComment : boolean?)
  774. local Comment = if InComment then "=" else ""
  775. return "CellId.new(--["..Comment.."[ Undocumented ]"..Comment.."])"
  776. end
  777. local function Serializevargs(... : any)
  778. local tbl = pack(...)
  779. local GenerationSize = 0
  780. for i = 1, #tbl do
  781. local Generation = Serialize(tbl[i], true, "")
  782. tbl[i] = Generation
  783. GenerationSize += #Generation
  784. if GenerationSize > 100000 then
  785. break
  786. end
  787. end
  788. return unpack(tbl, 1, tbl.n)
  789. end
  790. function Class.Convert<Type>(DataStructure : Type, format : boolean?)
  791. return Serialize(DataStructure, format, "")
  792. end
  793. function Class.ConvertKnown<Type>(DataType : string, DataStructure : Type, format : boolean?)
  794. return Methods[DataType](DataStructure, format, "")
  795. end
  796. function Class.print(... : any?)
  797. print(Serializevargs(...))
  798. end
  799. function Class.warn(... : any?)
  800. warn(Serializevargs(...))
  801. end
  802. if type(setclipboard) == "function" then
  803. local setclipboard = setclipboard
  804. function Class.setclipboard<Type>(DataStructure : Type, format : boolean?)
  805. setclipboard(Serialize(DataStructure, format, ""))
  806. end
  807. end
  808. return Class,Class.Methods
Advertisement
Add Comment
Please, Sign In to add comment