|
| 25 Jun 2013 08:43 PM |
--[[
CFrame Editor 2.0 Version: 1.0.07 Author: Crazyman32 (ROBLOX.com username) Created: November 9, 2012 Last updated: November 21, 2012 Lua: RBX.Lua (Lua 5.2)
CFrame Editor 2.0 is a ROBLOX Plugin, and should not be used for any other purpose. The primary purpose of this plugin is to provide quick and easy CFrame editing of ROBLOX parts and models. This was not designed to perform complicated manipulation algorithms. If you are interested in more complex editors, a good suggestion would be Anaminus' CmdUtil ROBLOX plugin.
Contact: ROBLOX: Crazyman32 Twitter: @RBX_Crazyman32 YouTube: ROBLOXcrazyman32
LICENSING:
All code (as well as the plugin image, cf.png) are Copyrighted © under the Creative Commons (CC BY-NC-SA) license. Full legal outline below:
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
(Summarized, don't sell or steal credit for this, however you can alter whatever you like and share it with others; open-source licensing basically.)
]] ---------------------------------------------------------------------------------------------------------------------------------- -- OPT: local CFNEW = CFrame.new local CFANG = CFrame.Angles local V3NEW = Vector3.new local DEGREES = math.deg local RADIANS = math.rad local UDIM2 = UDim2.new ----------------------------
-- I wrote all of this very quickly. It may look a bit unreadable. I appologize for my messy code.
local coreGui = game:GetService("CoreGui")
-- Initiated functions: local CloseClicked,MinimizeClicked,HelpClicked, NewMode,FormatIncrement,IncrementChanged, DragStopped,NewSelection,ArcHandles,Handles, CreateCenter,MouseClick,KeyDown,KeyUp
-- Holds event connectors for the mouse: local mouseConnections = {}
-- Some other miscellaneous initiations: local center,centerOrigin local curSelected = {}
-- Construct plugin: plugin = PluginManager():CreatePlugin() toolbar = plugin:CreateToolbar("Editor") button = toolbar:CreateButton("","CFrame Editor","cf.png") mouse = plugin:GetMouse()
local rbxGui = LoadLibrary("RbxGui") local selection = game:GetService("Selection")
local dragging = false local handles = Instance.new("Handles") handles.Name = "CFrameHandles" local arcHandles = Instance.new("ArcHandles") arcHandles.Name = "CFrameArcHandles" handles.Archivable,arcHandles.Archivable = false,false
-- Defined texts: local texts = { title = "CFrame Editor"; help = [[ MODE The current editor mode that the plug-in is tuned| to.
INCREMENT The increment of the movements of transform handles.
FREEFORM Hold SHIFT while dragging handles to enter Freeform mode,| where the increment is out of play. Use this when accuracy| is not necessarly needed. For instance, when making| natural-looking terrain.
MULTI-SELECT To select multiple objects, hold CTRL when clicking objects| in the game. ]]; } texts.help = texts.help:gsub("|\n"," ") -- Get rid of editor-friendly format
local colors = { red = BrickColor.new("Really red"); blue = BrickColor.new("Really blue"); yellow = BrickColor.new("New Yeller"); }
-- Editor mode types: local modes = { "Move"; "Rotate"; "Resize"; } local mode = modes[1] -- Current mode local modeFunctions = {} -- Allow modeFunctions to be called like a function: setmetatable(modeFunctions,{__call=function(t,...) t[mode](unpack({...})) end;__locked=true;})
-- Settings/configuration/properties of the modes: local modeSettings = { [modes[1]] = { -- MOVE increment = "Studs"; curInc = 1.0; maxInc = 2048.0; allowNegInc = false; allowMultiSelect = true; onSelection = function() if (center) then center:Destroy() center = nil end arcHandles.Parent = nil handles.Style = Enum.HandlesStyle.Movement if (#curSelected == 0) then handles.Parent = nil return end handles.Parent = coreGui if (#curSelected > 1 or (#curSelected == 1 and curSelected[1]:IsA("Model"))) then CreateCenter() handles.Adornee = center elseif (#curSelected == 1) then handles.Adornee = curSelected[1] end end; };
[modes[2]] = { -- ROTATE increment = "Degrees"; curInc = 45.0; maxInc = 360.0; allowNegInc = true; allowMultiSelect = true; onSelection = function() if (center) then center:Destroy() center = nil end handles.Parent = nil if (#curSelected == 0) then arcHandles.Parent = nil return end arcHandles.Parent = coreGui if (#curSelected > 1 or (#curSelected == 1 and curSelected[1]:IsA("Model"))) then CreateCenter() arcHandles.Adornee = center elseif (#curSelected == 1) then arcHandles.Adornee = curSelected[1] end end; };
[modes[3]] = { -- RESIZE increment = "Studs"; curInc = 1.0; maxInc = 2048.0; allowNegInc = false; allowMultiSelect = false; onSelection = function() if (center) then center:Destroy() center = nil end arcHandles.Parent = nil if (#curSelected == 0) then handles.Parent = nil return end handles.Style = Enum.HandlesStyle.Resize if (curSelected[1]:IsA("BasePart")) then handles.Parent = coreGui handles.Adornee = curSelected[1] else handles.Parent = nil end end; };
get = function(self,property) return self[mode][property] end;
set = function(self,property,value) self[mode][property] = value end; }
-- Normalize 255, 255, 255 color values local function RGB(r,g,b) return Color3.new((r/255),(g/255),(b/255)) end
-- Construct GUI: local createdGui = false local guiMain = Instance.new("ScreenGui",coreGui) guiMain.Archivable = false guiMain.Name = "CFrameEditorGui"
-- Initiated interfaces: local gui,container,closeButton,helpButton,minButton, minFrame,minFrameButton,helpFrame,modeSelect, increments,incrementsInput,incrementsFreeform
-- Main visible interface component: gui = Instance.new("Frame",guiMain) gui.Archivable = false gui.Visible = false gui.Draggable = true gui.Active = true gui.Name = "Main" gui.Size = UDIM2(0,200,0,20) gui.BackgroundColor3 = RGB(39,39,39) gui.BorderColor3 = Color3.new(0,0,0)
-- Build GUI: local function CreateGui() createdGui = true
-- Plugin title display: local title = Instance.new("TextLabel",gui) title.Name = "TitleBar" title.BackgroundTransparency = 1 title.Position = UDIM2(0,5,0,0) title.Size = UDIM2(1,-5,1,0) title.Font = Enum.Font.ArialBold title.FontSize = Enum.FontSize.Size18 title.Text = texts.title title.TextColor3 = Color3.new(1,1,1) title.TextStrokeColor3 = Color3.new(0,0,0) title.TextStrokeTransparency = 0 title.TextXAlignment = Enum.TextXAlignment.Left
-- Main container: container = Instance.new("Frame",gui) container.Name = "Container" container.BackgroundColor3 = RGB(72,72,72) container.BorderColor3 = Color3.new(0,0,0) container.Position = UDIM2(0,0,1,0) container.Size = UDIM2(1,0,0,110)
-- Minimize Frame: minFrame = Instance.new("Frame",gui) minFrame.Name = "MinimizeFrame" minFrame.BackgroundColor3 = RGB(72,72,72) minFrame.BorderColor3 = Color3.new(0,0,0) minFrame.Position = UDIM2(0,0,1,0) minFrame.Size = UDIM2(1,0,0,50) minFrame.Visible = false -- Minimize frame Show button: minFrameButton = Instance.new("TextButton",minFrame) minFrameButton.Name = "Show" minFrameButton.Position = UDIM2(0.5,-50,0.5,-20) minFrameButton.Size = UDIM2(0,100,0,40) minFrameButton.Style = Enum.ButtonStyle.RobloxButton minFrameButton.Font = Enum.Font.ArialBold minFrameButton.FontSize = Enum.FontSize.Size18 minFrameButton.Text = "Show" minFrameButton.TextColor3 = Color3.new(1,1,1)
-- Help frame: helpFrame = Instance.new("Frame",gui) helpFrame.Name = "HelpFrame" helpFrame.BackgroundColor3 = Color3.new(0,0,0) helpFrame.BorderSizePixel = 0 helpFrame.Position = UDIM2(1,5,0,0) helpFrame.Size = UDIM2(0,200,0,250) helpFrame.ZIndex = 3 helpFrame.Visible = false
-- Help text label: local helpText = Instance.new("TextLabel",helpFrame) helpText.Name = "HelpText" helpText.BackgroundTransparency = 1 helpText.Position = UDIM2(0,4,0,4) helpText.Size = UDIM2(1,-6,1,-6) helpText.ZIndex = 4 helpText.Font = Enum.Font.ArialBold helpText.FontSize = Enum.FontSize.Size12 helpText.Text = texts.help helpText.TextColor3 = Color3.new(1,1,1) helpText.TextWrapped = true helpText.TextXAlignment = Enum.TextXAlignment.Left helpText.TextYAlignment = Enum.TextYAlignment.Top
-- Close button: closeButton = Instance.new("TextButton",gui) closeButton.Name = "CloseButton" closeButton.BackgroundColor3 = RGB(20,20,20) closeButton.BorderSizePixel = 0 closeButton.Position = UDIM2(1,-16,0.5,-8) closeButton.Size = UDIM2(0,15,0,17) closeButton.Font = Enum.Font.ArialBold closeButton.FontSize = Enum.FontSize.Size14 closeButton.Text = "X" closeButton.TextColor3 = Color3.new(1,1,1) closeButton.BackgroundTransparency = 1
-- Minimize button: minButton = Instance.new("TextButton",gui) minButton.Name = "MinimizeButton" minButton.BackgroundColor3 = RGB(20,20,20) minButton.BorderSizePixel = 0 minButton.Position = UDIM2(1,-34,0.5,-8) minButton.Size = UDIM2(0,16,0,17) minButton.Font = Enum.Font.ArialBold minButton.FontSize = Enum.FontSize.Size14 minButton.Text = "-" minButton.TextColor3 = Color3.new(1,1,1) minButton.TextYAlignment = Enum.TextYAlignment.Top minButton.BackgroundTransparency = 1
-- Help button: helpButton = Instance.new("TextButton",gui) helpButton.Name = "HelpButton" helpButton.BackgroundColor3 = RGB(20,20,20) helpButton.BorderSizePixel = 0 helpButton.Position = UDIM2(1,-51,0.5,-8) helpButton.Size = UDIM2(0,15,0,17) helpButton.Font = Enum.Font.ArialBold helpButton.FontSize = Enum.FontSize.Size14 helpButton.Text = "?" helpButton.TextColor3 = Color3.new(1,1,1) helpButton.BackgroundTransparency = 1
-- Toolbar button separators: for _,x in pairs({-18,-35}) do local line = Instance.new("Frame",gui) line.Name = "SeparatingLine" line.BackgroundColor3 = RGB(115,115,115) line.BorderSizePixel = 0 line.Position = UDIM2(1,x,0.5,-7) line.Size = UDIM2(0,1,0,14) end
-- Mode select drop-down menu: local modeUpdate modeSelect,modeUpdate = rbxGui.CreateDropDownMenu(modes,NewMode) modeSelect.DropDownMenuButton.Text = modes[1] modeSelect.Name = "ModeDropDown" modeSelect.Position = UDIM2(0,5,0,20) modeSelect.Size = UDIM2(1,-10,0.01,25) modeSelect.Parent = container local modeLabel = Instance.new("TextLabel",container) modeLabel.Name = "ModeLabel" modeLabel.BackgroundTransparency = 1 modeLabel.Position = UDIM2(0,10,0,5) modeLabel.Size = UDIM2(1,-3,0,14) modeLabel.Font = Enum.Font.ArialBold modeLabel.FontSize = Enum.FontSize.Size14 modeLabel.Text = "Mode" modeLabel.TextColor3 = RGB(243,243,243) modeLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Increments component: increments = Instance.new("TextButton",container) increments.Name = "Increments" increments.Active = false increments.AutoButtonColor = false increments.Position = UDIM2(0,5,0,75) increments.Size = UDIM2(1,-10,0.01,25) increments.Style = Enum.ButtonStyle.RobloxButton increments.Font = Enum.Font.ArialBold increments.FontSize = Enum.FontSize.Size18 increments.Text = modeSettings:get("increment") increments.TextColor3 = Color3.new(1,1,1) increments.TextXAlignment = Enum.TextXAlignment.Right
-- Increments title: local incTitle = Instance.new("TextLabel",container) incTitle.Name = "IncrementsLabel" incTitle.BackgroundTransparency = 1 incTitle.Position = UDIM2(0,10,0,60) incTitle.Size = UDIM2(1,-3,0,14) incTitle.Font = Enum.Font.ArialBold incTitle.FontSize = Enum.FontSize.Size14 incTitle.Text = "Increment" incTitle.TextColor3 = Color3.new(1,1,1) incTitle.TextXAlignment = Enum.TextXAlignment.Left
-- Main input box for increment: incrementsInput = Instance.new("TextBox",increments) incrementsInput.Name = "Input" incrementsInput.BackgroundTransparency = 1 incrementsInput.Position = UDIM2(0,0,0,-8) incrementsInput.Size = UDIM2(1,0,1,16) incrementsInput.Font = Enum.Font.ArialBold incrementsInput.FontSize = Enum.FontSize.Size18 incrementsInput.TextColor3 = Color3.new(1,1,1) incrementsInput.TextXAlignment = Enum.TextXAlignment.Left FormatIncrement()
-- Overlay text for increment while in freeform mode: incrementsFreeform = Instance.new("TextLabel",increments) incrementsFreeform.Name = "Freeform" incrementsFreeform.BackgroundTransparency = 1 incrementsFreeform.Position = UDIM2(0,0,0,-8) incrementsFreeform.Size = UDIM2(1,0,1,16) incrementsFreeform.Font = Enum.Font.ArialBold incrementsFreeform.FontSize = Enum.FontSize.Size18 incrementsFreeform.Text = "Freeform" incrementsFreeform.TextColor3 = RGB(200,200,200) incrementsFreeform.TextXAlignment = Enum.TextXAlignment.Left incrementsFreeform.Visible = false
-- Simple color animation for toolbar buttons: for _,b in pairs({closeButton,minButton,helpButton}) do b.AutoButtonColor = false b.MouseEnter:connect(function() b.BackgroundTransparency = 0 end) b.MouseLeave:connect(function() if (b == helpButton) then -- Keep HelpButton 'active' if HelpFrame is visible if (not helpFrame.Visible) then b.BackgroundTransparency = 1 end else b.BackgroundTransparency = 1 end end) end
-- Set up button event connections: incrementsInput.FocusLost:connect(IncrementChanged) closeButton.MouseButton1Click:connect(CloseClicked) minButton.MouseButton1Click:connect(MinimizeClicked) helpButton.MouseButton1Click:connect(HelpClicked) minFrameButton.MouseButton1Click:connect(function() minFrame.Visible,container.Visible = false,true minButton.Text = "-" DragStopped() end) gui.DragStopped:connect(DragStopped) end -- END CreateGui
-- Create 'center' part for mutli-part manipulation: function CreateCenter() center = Instance.new("Part",game.Workspace) center.Name = "Center" center.Archivable = false center.Anchored,center.Locked,center.CanCollide = true,true,false center.Transparency = 1 center.TopSurface,center.BottomSurface = Enum.SurfaceType.Smooth,Enum.SurfaceType.Smooth center.FormFactor = Enum.FormFactor.Custom
-- Put all parts in a model temporarily to take advantage of model's GetModelSize/CFrame methods: local m = Instance.new("Model",game.Workspace) m.Name = "temp" local sel = {} for _,v in pairs(curSelected) do table.insert(sel,{v,v.Parent}) v.Parent = m end local cf,sz = CFrame.new(m:GetModelCFrame().p),m:GetModelSize() for _,v in pairs(sel) do v[1].Parent = v[2] end m:Destroy()
center.Size = sz center.CFrame = cf centerOrigin = center.CFrame mouse.TargetFilter = center end
-- Set selection: local ctrl = false local shift = false function MouseClick() Wait() if (dragging) then return end local target = mouse.Target local multi = modeSettings:get("allowMultiSelect") if (not target or (target and target.Locked and (not ctrl or not multi))) then selection:Set({}) return end local cur = selection:Get() local r = false -- 'r' stands for 'removed' local function modeled(obj) -- Get model that holds the part 'obj' (if it exists) for _,v in pairs(game.Workspace:GetChildren()) do if (v:IsAncestorOf(obj)) then return v end end return obj end -- Deselect part if it is already selected: for i,v in pairs(cur) do v = modeled(v) if (v == target) then r = true if (ctrl and multi) then table.remove(cur,i) else cur = {} end break end end -- Select part: if (not r) then target = modeled(target) if (ctrl and multi) then table.insert(cur,target) else cur = {target} end end selection:Set(cur) end
function KeyDown(k) local kb = k:byte() -- 'kb' stands for Key Bytecode if (kb == 49 or kb == 50) then -- 49 and 50 are both CTRL keys ctrl = true elseif (kb == 47 or kb == 48) then -- 47 and 48 are both SHIFT keys shift = true incrementsInput.Visible = false incrementsFreeform.Visible = true if (dragging) then handles.Color = colors.yellow arcHandles.Color = colors.yellow end end end
function KeyUp(k) local kb = k:byte() if (kb == 49 or kb == 50) then ctrl = false elseif (kb == 47 or kb == 48) then shift = false incrementsInput.Visible = true incrementsFreeform.Visible = false if (dragging) then handles.Color = colors.blue arcHandles.Color = colors.blue end end end
-- Special selection holder while using 3D handle objects: local dragSelection = { all = {}; -- Whole selection parts = {}; -- Only BaseParts in the selection getParts = function(self,parent) for _,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then table.insert(self.parts,{v,v.CFrame}) end self:getParts(v) end end; get = function(self) self.all = {} self.parts = {} for _,v in pairs(curSelected) do table.insert(self.all,{v,(v:IsA("Model") and v:GetModelCFrame().p or v.CFrame)}) if (v:IsA("BasePart")) then table.insert(self.parts,{v,v.CFrame}) else self:getParts(v) end end if (center) then table.insert(self.all,{center,center.CFrame}) end if (self.all[1][1]:IsA("BasePart")) then table.insert(self.all[1],self.all[1][1].Size) end end; } -- For optimization: local IdTop,IdBottom,IdFront,IdBack,IdRight,IdLeft = Enum.NormalId.Top,Enum.NormalId.Bottom,Enum.NormalId.Front, Enum.NormalId.Back,Enum.NormalId.Right,Enum.NormalId.Left local AxisX,AxisY,AxisZ = Enum.Axis.X,Enum.Axis.Y,Enum.Axis.Z
-- Get Drag Increment (Only used for modeFunctions.Move function): local function getDragInc(face,dist) local v if (face == IdTop) then v = V3NEW(0,dist,0) elseif (face == IdBottom) then v = V3NEW(0,-dist,0) elseif (face == IdFront) then v = V3NEW(0,0,-dist) elseif (face == IdBack) then v = V3NEW(0,0,dist) elseif (face == IdLeft) then v = V3NEW(-dist,0,0) else v = V3NEW(dist,0,0) end return v end
function modeFunctions.Move(face,dist,inc) -- MOVE if (not shift) then dist = (dist-(dist%inc)) end local inc = getDragInc(face,dist) if (#dragSelection.all == 1 and dragSelection.all[1][1]:IsA("BasePart")) then local v = dragSelection.all[1] v[1].CFrame = (v[2]*CFNEW(inc)) else for _,v in pairs(dragSelection.all) do if (v[1]:IsA("Model")) then v[1]:TranslateBy((v[2]+inc)-v[1]:GetModelCFrame().p) else v[1].CFrame = (v[2]+inc) end end end end
function modeFunctions.Rotate(axis,angle,radius,inc) -- ROTATE if (not shift) then angle = DEGREES(angle) angle = RADIANS(angle-(angle%inc)) end if (center) then local cf = center.CFrame local cf2 = (centerOrigin*CFANG( (axis == AxisX and angle or 0), (axis == AxisY and angle or 0), (axis == AxisZ and angle or 0) ) ) center.CFrame = cf2 for _,v in pairs(dragSelection.parts) do local p,cf3 = v[1],v[2] p.CFrame = (cf2*(centerOrigin:inverse()*cf3)) end else local p = dragSelection.all[1] local part,cf = p[1],p[2] part.CFrame = (cf*CFANG( (axis == AxisX and angle or 0), (axis == AxisY and angle or 0), (axis == AxisZ and angle or 0) ) ) end end
function modeFunctions.Resize(face,dist,inc) -- RESIZE if (not shift) then dist = (dist-(dist%inc)) end local p = dragSelection.all[1] local part,cf,sz = p[1],p[2],p[3] part.FormFactor = Enum.FormFactor.Custom if (face == IdTop or face == IdBottom) then if (dist < 0 and (sz.y+dist) < 0.2) then dist = (-sz.y+0.2) end part.Size = (sz+V3NEW(0,dist,0)) part.CFrame = (cf*CFNEW(0,((dist/2)*(face == IdTop and 1 or -1)),0)) elseif (face == IdFront or face == IdBack) then if (dist < 0 and (sz.z+dist) < 0.2) then dist = (-sz.z+0.2) end part.Size = (sz+V3NEW(0,0,dist)) part.CFrame = (cf*CFNEW(0,0,((dist/2)*(face == IdBack and 1 or -1)))) elseif (face == IdLeft or face == IdRight) then if (dist < 0 and (sz.x+dist) < 0.2) then dist = (-sz.x+0.2) end part.Size = (sz+V3NEW(dist,0,0)) part.CFrame = (cf*CFNEW(((dist/2)*(face == IdRight and 1 or -1)),0,0)) end end
function ArcHandles() local cDefault = colors.red local cDrag = colors.blue local cDragF = colors.yellow arcHandles.Color = cDefault local inc = 0 arcHandles.MouseButton1Down:connect(function() game:GetService("ChangeHistoryService"):SetWaypoint("ArcHandlesStart") dragging = true dragSelection:get() inc = modeSettings:get("curInc") arcHandles.Color = (shift and cDragF or cDrag) mouse.Button1Up:wait() if (center) then centerOrigin = center.CFrame end arcHandles.Color = cDefault dragging = false game:GetService("ChangeHistoryService"):SetWaypoint("ArcHandlesDone") end) arcHandles.MouseDrag:connect(function(axis,angle,radius) modeFunctions(axis,angle,radius,inc) end) end
function Handles() local cDefault = colors.red local cDrag = colors.blue local cDragF = colors.yellow handles.Color = cDefault local inc = 0 handles.MouseButton1Down:connect(function() game:GetService("ChangeHistoryService"):SetWaypoint("HandlesStart") dragging = true dragSelection:get() inc = modeSettings:get("curInc") handles.Color = (shift and cDragF or cDrag) mouse.Button1Up:wait() handles.Color = cDefault dragging = false game:GetService("ChangeHistoryService"):SetWaypoint("HandlesDone") end) handles.MouseDrag:connect(function(face,dist) modeFunctions(face,dist,inc) end) end
-- Called when you stop dragging the GUI object on your screen -- This makes sure the whole component is still visible on your screen -- If not, it will tween it back into a visible position: function DragStopped() local x,y = gui.AbsolutePosition.X,gui.AbsolutePosition.Y local c1 = (helpFrame.Visible and helpFrame or gui) local c2 = (container.Visible and container or minFrame) if (helpFrame.Visible) then if (helpFrame.AbsoluteSize.Y > c2.AbsoluteSize.Y) then c2 = helpFrame end end local padding = 5 -- Pixel padding from edge of screen local anim = false if (x < 0 or (x+gui.AbsoluteSize.X+(c1 ~= gui and (c1.AbsoluteSize.X+c1.Position.X.Offset) or 0)) > guiMain.AbsoluteSize.X) then anim = true x = (x < 0 and padding or (guiMain.AbsoluteSize.X-gui.AbsoluteSize.X-(c1 ~= gui and (c1.AbsoluteSize.X+c1.Position.X.Offset) or 0)-padding)) end if (y < 0 or (y+gui.AbsoluteSize.Y+c2.AbsoluteSize.Y) > guiMain.AbsoluteSize.Y) then anim = true y = (y < 0 and padding or (guiMain.AbsoluteSize.Y-gui.AbsoluteSize.Y-c2.AbsoluteSize.Y-padding)) end if (anim) then -- Tween back into sight: gui.Draggable = false gui:TweenPosition(UDIM2(0,x,0,y),"Out","Back",0.5,true,function() gui.Draggable = true end) end end
-- Called when there is a change to the objects selected in-game: function NewSelection() local all = {} for _,v in pairs(selection:Get()) do if (v:IsDescendantOf(game.Workspace) and (v:IsA("Model") or v:IsA("BasePart"))) then table.insert(all,v) end end curSelected = all if (gui.Visible) then modeSettings:get("onSelection")() end if (dragging) then dragSelection() end end
-- Format current increment for interface display: function FormatIncrement() local t = modeSettings:get("increment") local i = modeSettings:get("curInc") increments.Text = t incrementsInput.Text = ("%.2f"):format(i) end
-- Called when you input a number into the Increment text box: function IncrementChanged() local input = tonumber(incrementsInput.Text) if (input) then local max = modeSettings:get("maxInc") local neg = modeSettings:get("allowNegInc") if (not neg) then input = math.abs(input) end input = (input < -max and -max or input > max and max or input) modeSettings:set("curInc",input) end FormatIncrement() end
-- Close button clicked: function CloseClicked() button:SetActive(false) gui.Visible = false handles.Parent,arcHandles.Parent = nil,nil if (center) then center:Destroy() center = nil end for _,v in pairs(mouseConnections) do v:disconnect() end mouseConnections = {} end
-- Minimize button clicked: function MinimizeClicked() local switch = (not container.Visible) container.Visible = switch minFrame.Visible = not switch minButton.Text = (switch and "-" or "+") DragStopped() end
-- Help button clicked: function HelpClicked() helpFrame.Visible = (not helpFrame.Visible) DragStopped() end
-- Drop Down menu to select Mode has changed: function NewMode(strMode) mode = strMode FormatIncrement() modeSettings:get("onSelection")() end
-- Main plugin button clicked: button.Click:connect(function() if (not createdGui) then CreateGui() end local switch = (not gui.Visible) if (switch) then plugin:Activate(true) button:SetActive(true) mouse = plugin:GetMouse() gui.Position = UDIM2(0,5,0,5) -- Reset position mouseConnections = { -- Create mouse event connectors: mouse.Button1Down:connect(MouseClick); mouse.KeyDown:connect(KeyDown); mouse.KeyUp:connect(KeyUp); } NewSelection() else CloseClicked() end gui.Visible = switch end)
plugin.Deactivation:connect(function() button:SetActive(false) CloseClicked() end)
-- Get the necessary 3D manipulation objects ready: ArcHandles() Handles()
selection.SelectionChanged:connect(NewSelection)
[-] FʟᴀᴍᴇH1 ᴏɴ ᴛᴡɪᴛᴛᴇʀ [-]
Can you help me find it? lol |
|
|
| Report Abuse |
|