roblonium-web/Game/FinobeTools/DeleteTool.rbxm

492 lines
15 KiB
Plaintext

<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<External>null</External>
<External>nil</External>
<Item class="Tool" referent="RBX0">
<Properties>
<bool name="CanBeDropped">true</bool>
<bool name="Enabled">true</bool>
<CoordinateFrame name="Grip">
<X>0</X>
<Y>0</Y>
<Z>-0.5</Z>
<R00>0</R00>
<R01>0</R01>
<R02>1</R02>
<R10>1</R10>
<R11>0</R11>
<R12>0</R12>
<R20>0</R20>
<R21>1</R21>
<R22>0</R22>
</CoordinateFrame>
<string name="Name">DeleteTool</string>
<Content name="TextureId"><url>http://www.roblox.com/asset?id=73241901</url></Content>
<string name="ToolTip">Delete</string>
</Properties>
<Item class="Part" referent="RBX1">
<Properties>
<bool name="Anchored">false</bool>
<float name="BackParamA">-0.5</float>
<float name="BackParamB">0.5</float>
<token name="BackSurface">0</token>
<token name="BackSurfaceInput">0</token>
<float name="BottomParamA">-0.5</float>
<float name="BottomParamB">0.5</float>
<token name="BottomSurface">0</token>
<token name="BottomSurfaceInput">0</token>
<int name="BrickColor">199</int>
<CoordinateFrame name="CFrame">
<X>2.00618601</X>
<Y>76.3911819</Y>
<Z>-21.7047653</Z>
<R00>0.515998006</R00>
<R01>0.000676945958</R01>
<R02>-0.856589496</R02>
<R10>0.000997249852</R10>
<R11>-0.999999404</R11>
<R12>-0.000189550163</R12>
<R20>-0.856589139</R20>
<R21>-0.000756426307</R21>
<R22>-0.515998363</R22>
</CoordinateFrame>
<bool name="CanCollide">true</bool>
<float name="Elasticity">0.5</float>
<float name="Friction">0.300000012</float>
<float name="FrontParamA">-0.5</float>
<float name="FrontParamB">0.5</float>
<token name="FrontSurface">0</token>
<token name="FrontSurfaceInput">0</token>
<float name="LeftParamA">-0.5</float>
<float name="LeftParamB">0.5</float>
<token name="LeftSurface">0</token>
<token name="LeftSurfaceInput">0</token>
<bool name="Locked">true</bool>
<token name="Material">256</token>
<string name="Name">Handle</string>
<float name="Reflectance">0.400000006</float>
<float name="RightParamA">-0.5</float>
<float name="RightParamB">0.5</float>
<token name="RightSurface">0</token>
<token name="RightSurfaceInput">0</token>
<Vector3 name="RotVelocity">
<X>-0.0122278668</X>
<Y>-0.00862007216</Y>
<Z>0.00802176818</Z>
</Vector3>
<float name="TopParamA">-0.5</float>
<float name="TopParamB">0.5</float>
<token name="TopSurface">0</token>
<token name="TopSurfaceInput">0</token>
<float name="Transparency">0</float>
<Vector3 name="Velocity">
<X>-0.00655405503</X>
<Y>-0.014042181</Y>
<Z>0.000928968191</Z>
</Vector3>
<token name="formFactorRaw">2</token>
<token name="shape">1</token>
<Vector3 name="size">
<X>1</X>
<Y>0.800000012</Y>
<Z>3</Z>
</Vector3>
</Properties>
<Item class="SpecialMesh" referent="RBX2">
<Properties>
<token name="LODX">2</token>
<token name="LODY">2</token>
<Content name="MeshId"><url>http://www.roblox.com/asset/?id=16198309</url></Content>
<token name="MeshType">5</token>
<string name="Name">Mesh</string>
<Vector3 name="Offset">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Vector3>
<Vector3 name="Scale">
<X>1.20000005</X>
<Y>1.20000005</Y>
<Z>1.20000005</Z>
</Vector3>
<Content name="TextureId"><url>http://www.roblox.com/asset/?id=16198294</url></Content>
<Vector3 name="VertexColor">
<X>1</X>
<Y>1</Y>
<Z>1</Z>
</Vector3>
</Properties>
</Item>
<Item class="Sound" referent="RBX3">
<Properties>
<bool name="Looped">false</bool>
<string name="Name">Sound</string>
<float name="Pitch">1</float>
<bool name="PlayOnRemove">false</bool>
<Content name="SoundId"><url>http://www.roblox.com/Asset/?ID=12135982</url></Content>
<float name="Volume">0.699999988</float>
</Properties>
</Item>
</Item>
<Item class="LocalScript" referent="RBX4">
<Properties>
<bool name="Disabled">false</bool>
<Content name="LinkedSource"><null></null></Content>
<string name="Name">DeleteScript</string>
<ProtectedString name="Source">-- basic functions
function waitForChild(instance, name)
&#9;while not instance:FindFirstChild(name) do
&#9;&#9;instance.ChildAdded:wait()
&#9;end
end
function waitForProperty(instance, name)
&#9;while not instance[name] do
&#9;&#9;instance.Changed:wait()
&#9;end
end
-- locals
local RbxStamper = LoadLibrary(&quot;RbxStamper&quot;)
if not RbxStamper then
&#9;print(&quot;Error: RbxStamper Library Load Fail! Returning&quot;)
&#9;return nil
end
local Tool = script.Parent
enabled = true
game:GetService(&quot;ContentProvider&quot;):Preload(&quot;rbxasset://icons/delete_sel.png&quot;)
local cluster = nil
local selectionBox
local currentSelection
local currentSelectionColors = {}
local selectionLasso
local deleteDistance = 100
local player = nil
local highlight = false
local megaClusterSelectionBox = Instance.new(&quot;Part&quot;)
megaClusterSelectionBox.FormFactor = &quot;Custom&quot;
megaClusterSelectionBox.Size = Vector3.new(4, 4, 4) -- a little thicker than 4x4x4 unit clusterpart; just so selection box is more easily seen
megaClusterSelectionBox.Transparency = 1
megaClusterSelectionBox.Anchored = true
megaClusterSelectionBox.CanCollide = false
megaClusterSelectionBox.Parent = nil
waitForProperty(game,&quot;PlaceId&quot;)
local isRestricted = (game.PlaceId == 41324860 or game.PlaceId == 129686177)
local stampRegion = nil
local modelToStampIn = nil
waitForChild(Tool, &quot;AutoWedgeClusterParts&quot;)
local autoWedgeClusterParts = Tool.AutoWedgeClusterParts.Value
waitForChild(Tool, &quot;PlayerOwner&quot;)
local playerOwner = Tool.PlayerOwner
-- functions
function canDeleteObject(part)
&#9;-- let them delete anything that they created *or* anything on their baseplate
&#9;return part and not (part.Locked) and part:IsA(&quot;BasePart&quot;) and (part.Position - Tool.Parent.Head.Position).Magnitude &lt; deleteDistance and (isChildOfMyModel(part) or inBounds(part))
end
-- For Restricting Stamper Tool (isRestricted)
function inBounds(partOrModel)
&#9;if not stampRegion then return true end
&#9;if not partOrModel then return true end
&#9;
&#9;return RbxStamper.CanEditRegion(partOrModel, stampRegion)
end
function findModel(part)
&#9;if isRestricted then
&#9;&#9;while part ~= nil do
&#9;&#9;&#9;if part.className == &quot;Model&quot; and part.Name ~= modelToStampIn.Name and part.Name ~= &quot;GarbageParts&quot; then
&#9;&#9;&#9;&#9;return part
&#9;&#9;&#9;elseif part.Name == modelToStampIn.Name or part.Name == &quot;GarbageParts&quot; then
&#9;&#9;&#9;&#9;return nil
&#9;&#9;&#9;end
&#9;&#9;&#9;part = part.Parent
&#9;&#9;end
&#9;&#9;return nil
&#9;else
&#9;&#9;while part ~= game.Workspace do
&#9;&#9;&#9;if part:FindFirstChild(&quot;RobloxModel&quot;) then
&#9;&#9;&#9;&#9;return part
&#9;&#9;&#9;end
&#9;&#9;&#9;if part:IsA(&quot;Model&quot;) then
&#9;&#9;&#9;&#9;return part
&#9;&#9;&#9;end
&#9;&#9;&#9;part = part.Parent
&#9;&#9;end
&#9;&#9;return nil
&#9;end
end
function cleanOrphanedModel(parent)
&#9;if not parent then return end
&#9;if parent.className == &quot;Model&quot; then
&#9;&#9;local children = parent:GetChildren()
&#9;&#9;if #children == 0 and parent.Name ~= &quot;GarbageParts&quot; then
&#9;&#9;&#9;local oldParent = parent.Parent
&#9;&#9;&#9;parent:Remove()
&#9;&#9;&#9;cleanOrphanedModel(oldParent)
&#9;&#9;end
&#9;end
end
function isChildOfMyModel(part)
&#9;&#9;if not modelToStampIn then return true end
&#9;&#9;if modelToStampIn:IsAncestorOf(part) then
&#9;&#9;&#9;return true
&#9;&#9;else return false end
end
function on3dButton1Down(mouse)
&#9;local part = mouse.Target
&#9;if part == nil then
&#9;&#9;return
&#9;elseif part:IsA(&quot;Terrain&quot;) and not isRestricted then
&#9;&#9;if cluster ~= nil then
&#9;&#9;&#9;local cellPos = cluster:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
&#9;&#9;&#9;local autoWedgeCell = cluster.AutowedgeCell
&#9;&#9;&#9;local x = cellPos.x
&#9;&#9;&#9;local y = cellPos.y
&#9;&#9;&#9;local z = cellPos.z
&#9;&#9;&#9;cluster:SetCell(x, y, z, 0, 0, 0)
&#9;&#9;&#9;
&#9;&#9;&#9;if (autoWedgeClusterParts) then
&#9;&#9;&#9;&#9;for i = x - 1, x + 1 do
&#9;&#9;&#9;&#9;&#9;for j = y - 1, y + 1 do
&#9;&#9;&#9;&#9;&#9;&#9;for k = z - 1, z + 1 do
&#9;&#9;&#9;&#9;&#9;&#9;&#9;autoWedgeCell(cluster,i,j,k)
&#9;&#9;&#9;&#9;&#9;&#9;end
&#9;&#9;&#9;&#9;&#9;end
&#9;&#9;&#9;&#9;end
&#9;&#9;&#9;end
&#9;&#9;&#9;clearSelection()
&#9;&#9;&#9;on3dMouseMove(mouse)
&#9;&#9;end
&#9;elseif canDeleteObject(part) then
&#9;&#9;local model = findModel(part)
&#9;&#9;local oldParent
&#9;&#9;if model then
&#9;&#9;&#9;if currentSelection == model then
&#9;&#9;&#9;&#9;currentSelection = nil
&#9;&#9;&#9;&#9;clearSelection()
&#9;&#9;&#9;end
&#9;&#9;&#9;oldParent = model.Parent
&#9;&#9;&#9;model:Remove()
&#9;&#9;else
&#9;&#9;&#9;if currentSelection == part then
&#9;&#9;&#9;&#9;currentSelection = nil
&#9;&#9;&#9;&#9;clearSelection()
&#9;&#9;&#9;end
&#9;&#9;&#9;oldParent = part.Parent
&#9;&#9;&#9;part:Remove()
&#9;&#9;end
&#9;&#9;if isRestricted then
&#9;&#9;&#9;if oldParent and oldParent ~= modelToStampIn then
&#9;&#9;&#9;&#9;cleanOrphanedModel(oldParent)
&#9;&#9;&#9;end
&#9;&#9;else
&#9;&#9;&#9;cleanOrphanedModel(oldParent)
&#9;&#9;end
&#9;end
end
function saveSelectionColor(instance)
&#9;if instance:IsA(&quot;BasePart&quot;) then
&#9;&#9;currentSelectionColors[instance] = instance.BrickColor
&#9;&#9;if instance.BrickColor == BrickColor.Red() then
&#9;&#9;&#9;instance.BrickColor = BrickColor.new(&quot;Really red&quot;)
&#9;&#9;else
&#9;&#9;&#9;instance.BrickColor = BrickColor.Red()
&#9;&#9;end
&#9;end
end
&#9;
function setSelection(partOrModel)
&#9;if partOrModel ~= currentSelection then
&#9;&#9;clearSelection()
&#9;&#9;currentSelection = partOrModel
&#9;&#9;selectionBox.Adornee = currentSelection
&#9;end
end
function clearSelection()
&#9;if currentSelection ~= nil then
&#9;&#9;for part, color in pairs(currentSelectionColors) do
&#9;&#9;&#9;part.BrickColor = color
&#9;&#9;end
&#9;&#9;selectionBox.Adornee = nil
&#9;end
&#9;currentSelectionColors = {}
&#9;if currentSelection then currentSelection = nil end
&#9;if selectionBox then selectionBox.Adornee = nil end
&#9;megaClusterSelectionBox.Parent = nil
end
function on3dMouseMove(mouse)
&#9;local part = mouse.Target
&#9;if not part then
&#9;&#9;clearSelection()
&#9;&#9;return
&#9;elseif part:IsA(&quot;Terrain&quot;) and not isRestricted then
&#9;&#9;if not cluster then cluster = game.Workspace.Terrain end
&#9;&#9;local hitCell = cluster:WorldToCellPreferSolid(mouse.Hit.p)
&#9;&#9;if cluster:GetCell(hitCell.x, hitCell.y, hitCell.z).Value &gt; 0 then
&#9;&#9;&#9;megaClusterSelectionBox.CFrame = CFrame.new(cluster:CellCenterToWorld(hitCell.x, hitCell.y, hitCell.z))
&#9;&#9;&#9;if isRestricted then
&#9;&#9;&#9;&#9;megaClusterSelectionBox.Parent = game.Workspace.BaseplateBumpers
&#9;&#9;&#9;else
&#9;&#9;&#9;&#9;megaClusterSelectionBox.Parent = game.Workspace
&#9;&#9;&#9;end
&#9;&#9;&#9;selectionBox.Adornee = megaClusterSelectionBox
&#9;&#9;&#9;currentSelection = nil -- necessary so selection box can transition between terrain and non-terrain smoothly
&#9;&#9;else
&#9;&#9;&#9;clearSelection()
&#9;&#9;&#9;return
&#9;&#9;end
&#9;elseif canDeleteObject(part) then
&#9;&#9;local model = findModel(part)
&#9;&#9;if model then &#9;&#9;
&#9;&#9;&#9;selectionBox.Color = BrickColor.Red()
&#9;&#9;&#9;setSelection(model)
&#9;&#9;else
&#9;&#9;&#9;selectionBox.Color = BrickColor.Red()
&#9;&#9;&#9;setSelection(part)
&#9;&#9;end
&#9;else
&#9;&#9;clearSelection()
&#9;end
end
local equipCount = 0
function onEquippedLocal(mouse)
&#9;equipCount = equipCount + 1
&#9;local val = equipCount
&#9;if isRestricted then
&#9;&#9;waitForChild(game.Workspace, &quot;BuildingAreas&quot;)
&#9;&#9;if val ~= equipCount then
&#9;&#9;&#9;return
&#9;&#9;end
&#9;end
&#9;mouse.TargetFilter = megaClusterSelectionBox
&#9;local character = script.Parent.Parent
&#9;player = game.Players:GetPlayerFromCharacter(character)
&#9;
&#9;if not player then return end
&#9;if playerOwner.Value and playerOwner.Value ~= player then return end
&#9;playerOwner.Value = player
&#9;guiMain = Instance.new(&quot;ScreenGui&quot;)
&#9;guiMain.Parent = player.PlayerGui
&#9;mouse.Button1Down:connect(function() on3dButton1Down(mouse) end)
&#9;mouse.Move:connect(function() on3dMouseMove(mouse) end)
&#9;mouse.Icon = &quot;http://www.roblox.com/asset?id=72539748&quot;
&#9;selectionBox = Instance.new(&quot;SelectionBox&quot;)
&#9;selectionBox.Name = &quot;Model Delete Selection&quot;
&#9;selectionBox.Color = BrickColor.Red()
&#9;selectionBox.Adornee = nil
&#9;selectionBox.Parent = player.PlayerGui
&#9;selectionLasso = Instance.new(&quot;SelectionPartLasso&quot;)
&#9;selectionLasso.Name = &quot;Model Delete Lasso&quot;
&#9;selectionLasso.Humanoid = character.Humanoid
&#9;selectionLasso.archivable = false
&#9;selectionLasso.Visible = true
&#9;selectionLasso.Parent = game.workspace
&#9;selectionLasso.Color = BrickColor.Red()
&#9;highlight = true
end
function onUnequippedLocal()
&#9;highlight = false
&#9;if selectionBox then
&#9;&#9;clearSelection()
&#9;&#9;selectionBox:Remove()
&#9;end
&#9;if selectionLasso then selectionLasso:Remove() end
end
----------------------------------------------------------------------------------------
if isRestricted then -- setup our variables
&#9;waitForChild(game,&quot;Workspace&quot;)
&#9;waitForChild(game.Workspace, &quot;BuildingAreas&quot;)
&#9;waitForChild(game.Workspace.BuildingAreas, &quot;Area1&quot;)
&#9;waitForChild(game.Workspace.BuildingAreas, &quot;Area9&quot;) -- all areas loaded
&#9;while not modelToStampIn do -- check for build area until we find one
&#9;&#9;local buildAreas = game.Workspace.BuildingAreas:GetChildren()
&#9;&#9;for i = 1, #buildAreas do
&#9;&#9;&#9;if buildAreas[i]:IsA(&quot;Model&quot;) then
&#9;&#9;&#9;&#9;waitForChild(buildAreas[i],&quot;Player&quot;)
&#9;&#9;&#9;&#9;if buildAreas[i].Player.Value == game.Players.LocalPlayer.Name then
&#9;&#9;&#9;&#9;&#9;waitForChild(buildAreas[i],&quot;PlayerArea&quot;)
&#9;&#9;&#9;&#9;&#9;modelToStampIn = buildAreas[i].PlayerArea
&#9;&#9;&#9;&#9;&#9;break
&#9;&#9;&#9;&#9;end
&#9;&#9;&#9;end
&#9;&#9;end
&#9;&#9;if not modelToStampIn then
&#9;&#9;&#9;wait(0.5)
&#9;&#9;end
&#9;end
&#9;local lowPos = modelToStampIn.Parent:FindFirstChild(&quot;LowPos&quot;)
&#9;local highPos = modelToStampIn.Parent:FindFirstChild(&quot;HighPos&quot;)
&#9;if not lowPos or highPos then
&#9;&#9;wait(0.5)
&#9;&#9;lowPos = modelToStampIn.Parent:FindFirstChild(&quot;LowPos&quot;)
&#9;&#9;highPos = modelToStampIn.Parent:FindFirstChild(&quot;HighPos&quot;)
&#9;end
&#9;while lowPos.Value == Vector3.new(0,0,0) or highPos.Value == Vector3.new(0,0,0) do
&#9;&#9;wait(0.5)
&#9;end -- tool doesn&apos;t work until these are defined
&#9;stampRegion = Region3.new(lowPos.Value, highPos.Value) -- this is where we can stamp
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
</ProtectedString>
</Properties>
</Item>
<Item class="BoolValue" referent="RBX5">
<Properties>
<string name="Name">AutoWedgeClusterParts</string>
<bool name="Value">false</bool>
</Properties>
</Item>
<Item class="ObjectValue" referent="RBX6">
<Properties>
<string name="Name">PlayerOwner</string>
<Ref name="Value">null</Ref>
</Properties>
</Item>
</Item>
</roblox>