Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plugin = PluginManager():CreatePlugin()
- local toolbar = plugin:CreateToolbar("Compile Interface")
- local module = {}
- --[[
- Name: Model Compiler
- Author: popinman322 & nickcool9999 (partly!)
- Description: Compiles models (and Guis) into scripts
- Usage: Click the button over your selection :) It should be a GUI as that is what is mostly recognized.
- --]]
- local MemberNames = {'Version', 'Instance', 'ClassName', 'Name', 'Name', 'Color', 'Material', 'stop', 'stop', 'undo', 'undo', 'redo', 'redo', 'Camera', 'Offset', 'Scale', 'BaseUrl', 'Script', 'Render', 'FrameRateManager', 'Abort', 'Value', 'Sound', 'Priority', 'Time', 'Insert', 'Resize', 'Clone', 'Clone', 'MembershipType', 'ChatMode', 'Network', 'Ping', 'Size', 'Disabled', 'Heartbeat', 'Heartbeat', 'FriendRequestEvent', 'Faces', 'Axes', 'BrickColor', 'Part', 'Chat', 'Texture', 'Snap', 'Hole', 'Fire', 'Workspace', 'Humanoid', 'Controller', 'StarterScript', 'RequestQueueSize', 'CFrame', 'Lua', 'BinType', 'Slingshot', 'RobloxModelItem', 'CameraType', 'Jump', 'Torso', 'CoordinateFrame', 'FormFactor', 'MeshType', 'hasCustomStatus', 'removeStatus', 'hasStatus', 'addStatus', 'InOut', 'Boing', 'Bomb', 'Break', 'Click', 'Clock', 'Page', 'Splat', 'Step', 'StepOn', 'Swoosh', 'Victory', 'BodyPart', 'LeftLeg', 'RightLeg', 'Neutral', 'TopBottom', 'LeftRight', 'MoveState', 'Throttle', 'Steer', 'FontSize', 'Font', 'TextXAlignment', 'TextYAlignment', 'Pause', 'Pause', 'Style', 'SizeConstraint', 'ReportAbuse', 'shape', 'CanCollide', 'Anchored', 'Run', 'Run', 'Reset', 'Reset', 'Visible', 'TextColor', 'BackgroundColor', 'Locked', 'Position', 'Enabled', 'Selected', 'Browsable', 'Deprecated', 'Preliminary', 'ExplorerOrder', 'ExplorerImageIndex', 'LoadData', 'SaveData', 'SaveLeaderboardData', 'DataComplexity', 'DataComplexityLimit', 'DataReady', 'WaitForDataReady', 'RequestFriendship', 'RevokeFriendship', 'RemoteFriendServiceSignal', 'LoadString', 'SaveString', 'LoadBoolean', 'SaveBoolean', 'LoadNumber', 'SaveNumber', 'LoadInstance', 'SaveInstance', 'LoadCharacter', 'RemoveCharacter', 'SetUnder13', 'SetSuperSafeChat', 'SetMembershipType', 'SetAccountAge', 'HasBuildPermission', 'Character', 'CharacterAppearance', 'DistanceFromCharacter', 'GetFriendStatus', 'IsFriendsWith', 'IsBestFriendsWith', 'IsInGroup', 'SuperSafeChatReplicate', 'SimulationRadius', 'OsPlatform', 'TeamColor', 'Guest', 'MembershipTypeReplicate', 'AccountAgeReplicate', 'BuildPermissions', 'Chatted', 'Chatted', 'CharacterAdded', 'CharacterRemoving', 'Idled', 'FriendStatusChanged', 'Kill', 'ScriptSecurityError', 'RemoteInsert', 'RequestLock', 'LockResult', 'RequestUnlock', 'StatsAvailable', 'NumPlayers', 'MaxPlayers', 'GetPlayerByID', 'TeamChat', 'WhisperChat', 'PlayerChatted', 'GameAnnounce', 'GetPlayers', 'CreateLocalPlayer', 'SetAbuseReportUrl', 'SetChatFilterUrl', 'SetBuildToolsUrl', 'SetBuildUserPermissionsUrl', 'playerFromCharacter', 'GetPlayerFromCharacter', 'PlayerAddedEarly', 'PlayerAdded', 'PlayerRemoving', 'PlayerRemovingLate', 'SetSysStatsUrl', 'SetSysStatsUrlId', 'SetLoadDataUrl', 'SetSaveDataUrl', 'SetSaveLeaderboardDataUrl', 'AddLeaderboardKey', 'SetChatStyle', 'ClassicChat', 'Start', 'GetClientCount', 'SetIsPlayerAuthenticationRequired', 'IncommingConnection', 'ApplyNetworkSimulator', 'SetOutgoingKBPSLimit', 'Archivable', 'Archivable', 'IsA', 'IsA', 'FindFirstChild', 'FindFirstChild', 'Remove', 'Remove', 'GetChildren', 'GetChildren', 'GetFullName', 'GetFullName', 'IsDescendantOf', 'IsDescendantOf', 'IsAncestorOf', 'IsAncestorOf', 'GetDebugId', 'GetDebugId', 'DataCost', 'DataCost', 'Parent', 'Parent', 'RobloxLocked', 'RobloxLocked', 'ChildAdded', 'ChildAdded', 'ChildRemoved', 'ChildRemoved', 'DescendantAdded', 'DescendantAdded', 'DescendantRemoving', 'DescendantRemoving', 'AncestryChanged', 'AncestryChanged', 'Changed', 'Changed', 'Stepped', 'Stepped', 'DopplerScale', 'DopplerScale', 'DistanceFactor', 'DistanceFactor', 'RolloffScale', 'RolloffScale', 'AmbientReverb', 'AmbientReverb', 'PlayStockSound', 'PlayStockSound', 'SoundId', 'Volume', 'Pitch', 'PlayCount', 'Looped', 'IsPlaying', 'IsPaused', 'PlayOnRemove', 'Play', 'ReloadShaders', 'ReloadShaders', 'EnableQueue', 'EnableQueue', 'DisableQueue', 'DisableQueue', 'CaptureMetrics', 'CaptureMetrics', 'ResizeWindow', 'ResizeWindow', 'GetPresentTime', 'GetPresentTime', 'GetGPUDelay', 'GetGPUDelay', 'GetRenderAve', 'GetRenderAve', 'GetDeltaAve', 'GetDeltaAve', 'GetDrawCallBucketNum', 'GetDrawCallBucketNum', 'GetTriCount', 'GetTriCount', 'GetDrawCallBucketValue', 'GetDrawCallBucketValue', 'GetDrawCallBucketLimit', 'GetDrawCallBucketLimit', 'AddMaterialFilter', 'AddMaterialFilter', 'ClearMaterialFilter', 'ClearMaterialFilter', 'Score', 'AutoAssignable', 'AutoColorCharacters', 'SetCreateFriendRequestUrl', 'SetDeleteFriendRequestUrl', 'SetMakeFriendUrl', 'SetBreakFriendUrl', 'SetGetFriendsUrl', 'SetEnabled', 'SetEnabled', 'RemoteFriendEventSignal', 'RemoteFriendStatusSignal', 'Set', 'Set', 'ModelInPrimary', 'ModelInPrimary', 'PrimaryPart', 'BreakJoints', 'BreakJoints', 'MakeJoints', 'MakeJoints', 'GetModelSize', 'GetModelSize', 'GetModelCFrame', 'GetModelCFrame', 'location', 'MoveTo', 'MoveTo', 'TranslateBy', 'TranslateBy', 'SetWaypoint', 'SetWaypoint', 'ResetWaypoints', 'ResetWaypoints', 'GetCanUndo', 'GetCanUndo', 'GetCanRedo', 'GetCanRedo', 'NonScriptableAccess', 'CamelCaseViolation', 'AddStarterScript', 'RegisterRobloxLibrary', 'RegisterLibrary', 'RegisterDevelopmentLibrary', 'LibraryRegistrationComplete', 'AddCoreScript', 'SetTimeout', 'GetHeapStats', 'GetScriptStats', 'GarbageCollectionLimit', 'GarbageCollectionFrequency', 'SetCollectScriptStats', 'TextureId', 'Active', 'ReplicatedSelected', 'Deselected', 'ToggleSelect', 'Disable', 'ReplicatedSelectedConnectionCount', 'DeselectedConnectionCount', 'Grip', 'GripPos', 'GripForward', 'GripUp', 'GripRight', 'BackendToolState', 'ActivationState', 'Equipped', 'Unequipped', 'Activated', 'Deactivated', 'Source', 'LinkedSource', 'GetHash', 'DistributedGameTime', 'InsertContent', 'FindPartsInRegion3', 'FindPartOnRay', 'SetPhysicsThrottleEnabled', 'ZoomToExtents', 'CurrentCamera', 'ShowDevelopmentModelItem', 'AttachmentPoint', 'AttachmentPos', 'AttachmentForward', 'AttachmentUp', 'AttachmentRight', 'BackendAccoutrementState', 'Specular', 'Shiny', 'Transparency', 'StudsPerTileU', 'StudsPerTileV', 'SetBaseUrl', 'SetAssetUrl', 'SetThreadPool', 'SetCacheSize', 'Preload', 'GetRequestQueue', 'GetRequestedUrls', 'BlastRadius', 'BlastPressure', 'Hit', 'Focus', 'CameraSubject', 'Zoom', 'PanUnits', 'TiltUnits', 'BindButton', 'UnbindButton', 'GetButton', 'ButtonChanged', 'Velocity', 'RotVelocity', 'GetMass', 'Elasticity', 'Friction', 'AlphaModifier', 'Reflectance', 'ResizeableFaces', 'ResizeIncrement', 'NetworkIsSleeping', 'LocalSimulationTouched', 'Touched', 'OutfitChanged', 'DraggingV1', 'SetUploadUrl', 'GetUploadUrl', 'SetPing', 'RegisterActiveKeyframeSequence', 'RegisterKeyframeSequence', 'GetKeyframeSequence', 'AnimationId', 'MeshId', 'SetOldSchoolBackpack', 'GetOldSchoolBackpack', 'Health', 'MaxHealth', 'WalkSpeed', 'WalkToPart', 'WalkToPoint', 'TargetPoint', 'Sit', 'PlatformStand', 'WalkDirection', 'WalkAngleError', 'Strafe', 'TakeDamage', 'SetClickToWalkEnabled', 'Died', 'Running', 'Climbing', 'Jumping', 'FreeFalling', 'GettingUp', 'Strafing', 'FallingDown', 'Seated', 'PlatformStanding', 'HealthChanged', 'AddCustomStatus', 'RemoveCustomStatus', 'GetStatuses', 'StatusAdded', 'StatusRemoved', 'CustomStatusAdded', 'CustomStatusRemoved', 'LoadAnimation', 'GetSubPoses', 'AddSubPose', 'RemoveSubPose', 'Weight', 'MaskWeight', 'GetPoses', 'AddPose', 'RemovePose', 'GetKeyframes', 'AddKeyframe', 'RemoveKeyframe', 'Loop', 'TextColor3', 'TextTransparency', 'TextWrap', 'TextBounds', 'TextFits', 'Image', 'Duration', 'AllowTeamChangeOnTouch', 'Graphic', 'Outfit1', 'Outfit2', 'ShirtTemplate', 'PantsTemplate', 'SkinColor', 'HeadColor', 'LeftArmColor', 'RightArmColor', 'TorsoColor', 'LeftLegColor', 'RightLegColor', 'RebalanceTeams', 'RebalanceTeams', 'GetTeams', 'GetTeams', 'SetFriendUrl', 'SetBestFriendUrl', 'SetGroupUrl', 'SetStuffUrl', 'SetPackageContentsUrl', 'MinValue', 'MaxValue', 'ConstrainedValue', 'TweenSizeAndPosition', 'TweenPosition', 'TweenSize', 'BorderSizePixel', 'ZIndex', 'BorderColor', 'BorderColor3', 'BackgroundColor3', 'BackgroundTransparency', 'Draggable', 'MouseEnter', 'MouseLeave', 'MouseMoved', 'DragStopped', 'DragBegin', 'MouseEnterConnectionCount', 'MouseLeaveConnectionCount', 'MouseMovedConnectionCount', 'DragStoppedConnectionCount', 'DragBeginConnectionCount', 'SetVerb', 'MouseButton1Click', 'MouseButton2Click', 'MouseButton1Down', 'MouseButton1Up', 'MouseButton2Down', 'MouseButton2Up', 'MouseButton1ClickConnectionCount', 'MouseButton2ClickConnectionCount', 'MouseButton1DownConnectionCount', 'MouseButton1UpConnectionCount', 'MouseButton2DownConnectionCount', 'MouseButton2UpConnectionCount', 'AutoButtonColor', 'Modal', 'InsertRequest', 'InsertRequestAsset', 'InsertRequestAssetVersion', 'InsertReady', 'InsertError', 'SetBaseCategoryUrl', 'SetUserCategoryUrl', 'SetTrustLevel', 'SetBaseSetsUrl', 'SetUserSetsUrl', 'SetFreeModelUrl', 'SetFreeDecalUrl', 'SetCollectionUrl', 'SetAssetVersionUrl', 'GetBaseCategories', 'GetUserCategories', 'SetAdvancedResults', 'GetFreeModels', 'GetFreeDecals', 'GetBaseSets', 'GetUserSets', 'GetCollection', 'GetCollection', 'LoadAsset', 'LoadAssetVersion', 'SetAccessKey', 'MultiLine', 'ClearTextOnFocus', 'CaptureFocus', 'FocusLost', 'LightingChanged', 'LightingChanged', 'TimeOfDay', 'TimeOfDay', 'GeographicLatitude', 'GeographicLatitude', 'GetMoonPhase', 'GetMoonPhase', 'GetMoonDirection', 'GetMoonDirection', 'GetSunDirection', 'GetSunDirection', 'GetMinutesAfterMidnight', 'GetMinutesAfterMidnight', 'SetMinutesAfterMidnight', 'SetMinutesAfterMidnight', 'ShadowColor', 'ShadowColor', 'Brightness', 'Brightness', 'ColorShift_Top', 'ColorShift_Top', 'ColorShift_Bottom', 'ColorShift_Bottom', 'Ambient', 'Ambient', 'Part0', 'Part1', 'Surface0', 'Surface1', 'C0', 'C1', 'F0', 'F1', 'F2', 'F3', 'BaseAngle', 'MaxVelocity', 'DesiredAngle', 'SetDesiredAngle', 'CurrentAngle', 'AssemblyAdded', 'AssemblyRemoved', 'Bevel', 'Bevel Roundness', 'Bulge', 'LODX', 'LODY', 'VertexColor', 'Adornee', 'StudsOffset', 'ExtentsOffset', 'SizeOffset', 'BaseTextureId', 'OverlayTextureId', 'MouseClick', 'FrontendMouseClick', 'MaxActivationDistance', 'ItemAdded', 'ItemAdded', 'ItemRemoved', 'ItemRemoved', 'ClickButton1', 'ClickButton1', 'Button1Down', 'Button1Down', 'Button1Up', 'Button1Up', 'ClickButton2', 'ClickButton2', 'Button2Down', 'Button2Down', 'Button2Up', 'Button2Up', 'MoveMouse', 'MoveMouse', 'TypeKey', 'TypeKey', 'SetKeyDown', 'SetKeyDown', 'SetKeyUp', 'SetKeyUp', 'MaxItems', 'MaxItems', 'AddItem', 'AddItem', 'SetLegacyMaxItems', 'SetLegacyMaxItems', 'InitialPrompt', 'Purpose', 'Tone', 'ConversationDistance', 'InUse', 'SignalDialogChoiceSelected', 'DialogChoiceSelected', 'UserDialog', 'ResponseDialog', 'Description', 'Timeout', 'Ended', 'Failed', 'SetCookieValue', 'SetCookieValue', 'GetCookieValue', 'GetCookieValue', 'DeleteCookieValue', 'DeleteCookieValue', 'FaceId', 'SecondaryColor', 'Heat', 'size_xml', 'heat_xml', 'FlagCaptured', 'Target', 'TargetOffset', 'TargetRadius', 'MaxSpeed', 'MaxThrust', 'ThrustP', 'ThrustD', 'TurnP', 'TurnD', 'MaxTorque', 'CartoonFactor', 'ReachedTarget', 'maxForce', 'lastForce', 'GetLastForce', 'angularvelocity', 'force', 'MouseDrag', 'MouseDragConnectionCount', 'SkyboxUp', 'SkyboxLf', 'SkyboxRt', 'SkyboxBk', 'SkyboxFt', 'SkyboxDn', 'StarCount', 'CelestialBodiesShown', 'StickyWheels', 'MoveStateChanged', 'ControllingHumanoid', 'ApplySpecificImpulse', 'AxisChanged', 'Opacity', 'RiseVelocity', 'opacity_xml', 'riseVelocity_xml', 'SparkleColor', 'TargetSurface', 'TurnSpeed', 'Torque', 'HeadsUpDisplay', 'AreHingesDetected', 'MouseDown', 'MouseMove', 'MouseUp', 'AxisRotate', 'TopSurface', 'TopSurfaceInput', 'TopParamA', 'TopParamB', 'BottomSurface', 'BottomSurfaceInput', 'BottomParamA', 'BottomParamB', 'LeftSurface', 'LeftSurfaceInput', 'LeftParamA', 'LeftParamB', 'RightSurface', 'RightSurfaceInput', 'RightParamA', 'RightParamB', 'FrontSurface', 'FrontSurfaceInput', 'FrontParamA', 'FrontParamB', 'BackSurface', 'BackSurfaceInput', 'BackParamA', 'BackParamB', 'AbsoluteSize', 'AbsolutePosition', 'UserHasBadge', 'AwardBadge', 'IsDisabled', 'IsLegal', 'SetHasBadgeCooldown', 'SetAwardBadgeUrl', 'SetHasBadgeUrl', 'SetIsBadgeDisabledUrl', 'SetIsBadgeLegalUrl', 'SetFilterUrl', 'SetFilterLimits', 'KeyPressed', 'SpecialKeyPressed', 'AddKey', 'AddSpecialKey', 'SendNotification', 'AddCenterDialog', 'RemoveCenterDialog', 'SetGlobalSizeOffsetPixel', 'ShowLegacyPlayerList', 'Text', 'TopImage', 'ScrollBarThickness', 'ScrollingEnabled', 'CanvasSize', 'CanvasPosition', 'BottomImage', 'MidImage'}
- local ManualBlacklist = {
- GuiObject = {
- Transparency = true,
- BackgroundColor = true,
- TextColor = true
- }
- }
- local NewLine = string.char(0x0d) .. string.char(0x0a)
- local Tab = [[ ]]
- function approx(number)
- -- omit insignificant digits in a number
- local str = tostring(number)
- local z = 0
- local cur = ""
- for i = 1, str:len() do
- if str:sub(i, i) == "0" then
- z=z+1
- elseif z < 4 then
- cur=cur..string.rep("0", z) .. str:sub(i, i)
- z = 0
- end
- end
- -- if answer is 0 then converting will be nil, return 0 instead
- return tonumber(cur) or 0
- end
- function approxc3(tab)
- -- omit insignificant digits in color3 table
- local cur=""
- for i = 1, #tab do
- if tab[i] ~= 0 and tab[i] ~= 1 then
- cur = cur.. (tab[i]*255).. "/255"
- else
- cur = cur.. tab[i]
- end
- if i ~= #tab then
- cur=cur..", "
- end
- end
- return cur
- end
- function omitStr(str, omit)
- -- omit characters from a string
- local cur = ""
- for i = 1, str:len() do
- local check = true
- for x = 1, omit:len() do
- if str:sub(i, i) == omit:sub(x, x) then
- check = false
- end
- end
- if check then
- cur = cur .. str:sub(i, i)
- end
- end
- return cur
- end
- function isBlacklisted(item, prop)
- for n,c in pairs(ManualBlacklist) do
- if item:IsA(n) then
- return c[prop] or false
- end
- end
- return false
- end
- function isProp(item, prop)
- local check = true
- local Safe, Return = pcall(function() return item[prop] end)
- local NSafe, New = pcall(function() return Instance.new(item.ClassName) end)
- if not Safe or not NSafe then check = -1 end
- if type(Return) == "function" then check = -2 end
- if pcall(function() return Return["connect"] end) and Return["connect"] ~= nil then check = -3 end
- if not pcall(function() New[prop] = New[prop] end) then check = -4 end
- if isBlacklisted(item, prop) then check = -5 end
- return (check == true)
- end
- function isObject(item)
- if isProp(item, "Name") and isProp(item, "ClassName") then
- return true
- end
- return false
- end
- function GetProps(item)
- local Props = {}
- local Done = {}
- for _, name in pairs(MemberNames) do
- if isProp(item, name) and not Done[name] then Done[name] = 0 table.insert(Props, name) end
- end
- return Props
- end
- function HandleUData(item)
- if item == nil then return end
- local Safe, Tab = pcall(function() return loadstring("return {" .. tostring(item) .. "}")() end)
- if not Safe then
- if BrickColor.new(tostring(item)) == item then
- return "BrickColor.new(\"" .. tostring(item) .. "\")"
- end
- end
- local Safe2, IsUDim = pcall(function() return loadstring("return {" .. tostring(#Tab[2]) .. "}")() end)
- if #Tab == 3 then
- if pcall(function() local a = item.r; end) then
- return "Color3.new(" .. approxc3(Tab) .. ")"
- else
- return "Vector3.new(" .. tostring(item) .. ")"
- end
- elseif #Tab == 12 then
- return "CFrame.new(" .. tostring(item) .. ")"
- elseif #Tab == 2 and Safe2 then
- return "UDim2.new(" .. omitStr(tostring(item), "{}") .. ")"
- elseif #Tab == 1 then -- Should be an Enum
- return tostring(item)
- elseif #Tab == 0 then
- if isObject(item) then return "nil" end
- if BrickColor.new(tostring(item)) == item then
- return "BrickColor.new(\"" .. tostring(item) .. "\")"
- end
- elseif #Tab > 10 then
- local Safe, Return = pcall(function()
- return "UDim2.new(" .. item.X.Scale .. ", " .. item.X.Offset .. ", " .. item.Y.Scale .. ", " .. item.Y.Offset .. ")"
- end)
- if Return then return Return end
- end
- return ""
- end
- function PToString(item, prop)
- local Prop = item[prop]
- if type(Prop) == "userdata" or type(Prop) == "nil" or not type(Prop) then
- return HandleUData(Prop)
- elseif type(Prop) == "string" then
- return "\"" .. Prop .. "\""
- elseif type(Prop) == "number" then
- return tostring(approx(Prop))
- elseif type(Prop) == "string" then
- return "\"" .. Prop .. "\""
- elseif type(Prop) == "table" then
- return "{}"
- elseif type(Prop) == "boolean" then
- if Prop then return "true" else return "false" end
- end
- print(type(Prop))
- return ""
- end
- accounted={}
- count=0
- function Compile(ModelItem, ParentName, TableName, Storage, Index, Level, FullName)
- count=count+1
- FullName=FullName or ""
- if not ModelItem then return end
- local Props = GetProps(ModelItem)
- local Safe, New = pcall(function() return Instance.new(ModelItem.ClassName) end)
- if not Safe then print("Cannot compile ModelItem, ERR_NEW_INSTANCE") return end
- if not ParentName then -- This is the root of the model
- Storage = {}
- Index = 1
- Level = 1
- TableName = TableName or "CompiledModel"
- ParentName = "nil"
- FullName = FullName .. "." .. ModelItem.Name
- table.insert(Storage, "comp={}" ..NewLine)
- table.insert(Storage, "function comp." ..ModelItem.Name.. "()" ..NewLine)
- table.insert(Storage, Tab.. "local " .. TableName .. " = {}")
- local Self = TableName .. "." .. FullName:sub(2)
- table.insert(Storage, NewLine .. string.rep(Tab, Level+1) .. Self .. " = Instance.new(\"" .. ModelItem.ClassName .. "\", " .. ParentName .. ")")
- for _, prop in pairs(Props) do
- if ModelItem[prop] ~= New[prop] and prop ~= "Parent" then
- table.insert(Storage, NewLine)
- table.insert(Storage, string.rep(Tab, Level+1) .. Self .. "[\"" .. prop .. "\"] = " .. PToString(ModelItem, prop))
- end
- end
- for _, child in pairs(ModelItem:GetChildren()) do
- Compile(child, Self, TableName, Storage, Index + 1, Level + 1, FullName)
- end
- table.insert(Storage, NewLine)
- table.insert(Storage, Tab.."return " ..TableName)
- table.insert(Storage, NewLine)
- table.insert(Storage, "end" .. NewLine.. "return comp." ..ModelItem.Name.. "()")
- accounted[ModelItem.Name]=(accounted[ModelItem.Name] or 0)+1
- return table.concat(Storage, "")
- else
- FullName = FullName .. "." .. ModelItem.Name
- accounted[ModelItem.Name]=(accounted[ModelItem.Name] or 0)+1
- local Self
- if accounted[ModelItem.Name] > 1 then
- Self = TableName .. "[\"" .. FullName:sub(2) .. accounted[ModelItem.Name] .. "\"]"
- else
- Self = TableName .. "[\"" .. FullName:sub(2) .. "\"]"
- end
- table.insert(Storage, NewLine)
- table.insert(Storage, string.rep(Tab, Level+1) .. string.rep("-", 2) .. " " ..TableName.. FullName)
- table.insert(Storage, NewLine)
- table.insert(Storage, string.rep(Tab, Level+1) .. Self .. " = Instance.new(\"" .. ModelItem.ClassName .. "\", " .. ParentName .. ")")
- for _, prop in pairs(Props) do
- if ModelItem[prop] ~= New[prop] and prop ~= "Parent" then
- table.insert(Storage, NewLine)
- table.insert(Storage, string.rep(Tab, Level+1) .. Self .. "[\"" .. prop .. "\"] = " .. PToString(ModelItem, prop))
- end
- end
- for _, child in pairs(ModelItem:GetChildren()) do
- Compile(child, Self, TableName, Storage, Index + 1, Level + 1, FullName)
- end
- end
- end
- module.Compiler = {}
- module.Compiler.Compile = function(...)
- count = 0
- return Compile(...)
- end
- module.Quick = function(selection)
- if #selection ~= 1 then print 'must have only 1 selection' return end
- local tmp = selection[1]
- local par = tmp.Parent
- local s
- local c=0
- while par:FindFirstChild("CompiledModel" ..c+1) do c=c+1 wait() end
- s = Instance.new("ModuleScript", par)
- s.Name = "Interface" ..(c+1)
- count = 0
- s.Source = Compile(tmp, nil, "Interface")
- end
- local button = toolbar:CreateButton("Compile Item to ModuleScript", "Compiles items into ModuleScripts (Preferably Interfaces).", "")
- button.Click:connect(function()
- local selection = game.Selection:Get()
- local sel = game.Selection
- module.Quick(selection)
- end)
Advertisement
Add Comment
Please, Sign In to add comment