Formatting improvements to terrain plugins
This commit is contained in:
parent
37f3892695
commit
ba510b060a
|
|
@ -33,9 +33,9 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local SetCells = c.SetCells
|
local SetCells = c.SetCells
|
||||||
local AutoWedge = c.AutowedgeCells
|
local AutoWedge = c.AutowedgeCells
|
||||||
|
|
@ -130,9 +130,10 @@ local hideGenerateConformation = false
|
||||||
--GUI-
|
--GUI-
|
||||||
------
|
------
|
||||||
--screengui
|
--screengui
|
||||||
local g = Instance.new "ScreenGui"
|
local g = New "ScreenGui" {
|
||||||
g.Name = "TerrainCreatorGui"
|
Name = "TerrainCreatorGui",
|
||||||
g.Parent = CoreGui
|
Parent = CoreGui,
|
||||||
|
}
|
||||||
|
|
||||||
-- UI gui load. Required for sliders.
|
-- UI gui load. Required for sliders.
|
||||||
local RbxGui = LoadLibrary "RbxGui"
|
local RbxGui = LoadLibrary "RbxGui"
|
||||||
|
|
@ -161,7 +162,7 @@ local function helpText()
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
TextYAlignment = Enum.TextYAlignment.Top,
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
TextWrap = true,
|
TextWrapped = true,
|
||||||
Parent = terrainHelpFrame,
|
Parent = terrainHelpFrame,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
@ -368,30 +369,6 @@ local function CreateStandardSlider(
|
||||||
return sliderGui, sliderPosition
|
return sliderGui, sliderPosition
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a standard dropdown. Use this for all dropdowns in the popup so it is easy to standardize.
|
|
||||||
-- name - What to set the text label name as.
|
|
||||||
-- pos - Where to position the label. Should be of type UDim2.
|
|
||||||
-- values - A table of the values that will be in the dropbox, in the order they are to be shown.
|
|
||||||
-- initValue - Initial value the dropdown should be set to.
|
|
||||||
-- funcOnChange - Function to run when a dropdown selection is made.
|
|
||||||
-- parent - What to set the parent as.
|
|
||||||
-- Return:
|
|
||||||
-- dropdown - The dropdown gui.
|
|
||||||
-- updateSelection - Object to use to change the current dropdown.
|
|
||||||
-- function CreateStandardDropdown(name, pos, values, initValue, funcOnChange, parent)
|
|
||||||
-- -- Create a dropdown selection for the modes to fill in a river
|
|
||||||
-- local dropdown, updateSelection = RbxGui.CreateDropDownMenu(values, funcOnChange)
|
|
||||||
-- dropdown.Name = name
|
|
||||||
-- dropdown.Position = pos
|
|
||||||
-- dropdown.Active = true
|
|
||||||
-- dropdown.Size = UDim2.new(0, 150, 0, 32)
|
|
||||||
-- dropdown.Parent = parent
|
|
||||||
|
|
||||||
-- updateSelection(initValue)
|
|
||||||
|
|
||||||
-- return dropdown, updateSelection
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local cancelValues = {
|
local cancelValues = {
|
||||||
cancelAction = false, -- Used to cancel currently occuring actions. If set to true then terrain generation will stop.
|
cancelAction = false, -- Used to cancel currently occuring actions. If set to true then terrain generation will stop.
|
||||||
progressBar = nil, -- Will store the progress bar when needed.
|
progressBar = nil, -- Will store the progress bar when needed.
|
||||||
|
|
@ -594,7 +571,7 @@ end
|
||||||
-- centerX, centerZ - Center coordinate of land. This doesn't take into account clipping.
|
-- centerX, centerZ - Center coordinate of land. This doesn't take into account clipping.
|
||||||
-- length, width - Land dimensions.
|
-- length, width - Land dimensions.
|
||||||
local function SetCamera(centerX, centerZ, length, width, height)
|
local function SetCamera(centerX, centerZ, length, width, height)
|
||||||
local currCamera = game.Workspace.CurrentCamera
|
local currCamera = workspace.CurrentCamera
|
||||||
local cameraPos = Vector3.new(0, 400, 1600)
|
local cameraPos = Vector3.new(0, 400, 1600)
|
||||||
local cameraFocus = Vector3.new(0, height * 4, 0)
|
local cameraFocus = Vector3.new(0, height * 4, 0)
|
||||||
|
|
||||||
|
|
@ -648,8 +625,8 @@ local function GenerateTerrain()
|
||||||
|
|
||||||
--Generate Terrain
|
--Generate Terrain
|
||||||
-- offset terrain additionally by whatever the smallest cell is
|
-- offset terrain additionally by whatever the smallest cell is
|
||||||
--xpos2 = generateOptions.xpos + game.Workspace.Terrain.MaxExtents.Min.X
|
--xpos2 = generateOptions.xpos + workspace.Terrain.MaxExtents.Min.X
|
||||||
--zpos2 = generateOptions.zpos + game.Workspace.Terrain.MaxExtents.Min.Z
|
--zpos2 = generateOptions.zpos + workspace.Terrain.MaxExtents.Min.Z
|
||||||
local xpos2 = generateOptions.xpos - generateOptions.width / 2
|
local xpos2 = generateOptions.xpos - generateOptions.width / 2
|
||||||
local zpos2 = generateOptions.zpos - generateOptions.length / 2
|
local zpos2 = generateOptions.zpos - generateOptions.length / 2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
||||||
|
|
@ -48,11 +48,12 @@ local SetWaterCell = c.SetWaterCell
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
-- Stores selection properties.
|
-- Stores selection properties.
|
||||||
local selectionProps = {}
|
local selectionProps = {
|
||||||
selectionProps.isWater = nil -- True if what will be built is water.
|
isWater = nil, -- True if what will be built is water.
|
||||||
selectionProps.waterForce = nil -- Water force.
|
waterForce = nil, -- Water force.
|
||||||
selectionProps.waterDirection = nil -- Water direction.
|
waterDirection = nil, -- Water direction.
|
||||||
selectionProps.terrainMaterial = 0 -- Terrain material to use
|
terrainMaterial = 0, -- Terrain material to use
|
||||||
|
}
|
||||||
|
|
||||||
-- What color to use for the mouse highlighter.
|
-- What color to use for the mouse highlighter.
|
||||||
local mouseHighlightColor = BrickColor.new "Lime green"
|
local mouseHighlightColor = BrickColor.new "Lime green"
|
||||||
|
|
@ -125,7 +126,7 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
-- success - Value is true if there was a plane intersection, false if not.
|
-- success - Value is true if there was a plane intersection, false if not.
|
||||||
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
||||||
function PlaneIntersection(vectorPos)
|
function PlaneIntersection(vectorPos)
|
||||||
local currCamera = game.Workspace.CurrentCamera
|
local currCamera = workspace.CurrentCamera
|
||||||
local startPos = Vector3.new(
|
local startPos = Vector3.new(
|
||||||
currCamera.CoordinateFrame.p.X,
|
currCamera.CoordinateFrame.p.X,
|
||||||
currCamera.CoordinateFrame.p.Y,
|
currCamera.CoordinateFrame.p.Y,
|
||||||
|
|
@ -249,20 +250,23 @@ end)
|
||||||
|
|
||||||
builderHelpFrame.Size = UDim2.new(0, 160, 0, 85)
|
builderHelpFrame.Size = UDim2.new(0, 160, 0, 85)
|
||||||
|
|
||||||
local builderHelpText = Instance.new "TextLabel"
|
local helpText = [[
|
||||||
builderHelpText.Name = "HelpText"
|
|
||||||
builderHelpText.Font = Enum.Font.ArialBold
|
|
||||||
builderHelpText.FontSize = Enum.FontSize.Size12
|
|
||||||
builderHelpText.TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255)
|
|
||||||
builderHelpText.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
builderHelpText.TextYAlignment = Enum.TextYAlignment.Top
|
|
||||||
builderHelpText.Position = UDim2.new(0, 4, 0, 4)
|
|
||||||
builderHelpText.Size = UDim2.new(1, -8, 0, 177)
|
|
||||||
builderHelpText.BackgroundTransparency = 1
|
|
||||||
builderHelpText.TextWrap = true
|
|
||||||
builderHelpText.Text = [[
|
|
||||||
Clicking terrain adds a single block into the selection box shown. The terrain material and type will be the same as the cell that was clicked on.]]
|
Clicking terrain adds a single block into the selection box shown. The terrain material and type will be the same as the cell that was clicked on.]]
|
||||||
builderHelpText.Parent = builderHelpFrame
|
|
||||||
|
New "TextLabel" {
|
||||||
|
Name = "HelpText",
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size12,
|
||||||
|
TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255),
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
|
Position = UDim2.new(0, 4, 0, 4),
|
||||||
|
Size = UDim2.new(1, -8, 0, 177),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextWrapped = true,
|
||||||
|
Text = helpText,
|
||||||
|
Parent = builderHelpFrame,
|
||||||
|
}
|
||||||
|
|
||||||
CreateStandardLabel(
|
CreateStandardLabel(
|
||||||
"AddText",
|
"AddText",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
||||||
local CoreGui = game:GetService "CoreGui"
|
local CoreGui = game:GetService "CoreGui"
|
||||||
|
|
||||||
local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
||||||
|
local New = require("../Modules/New").New
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
--DEFAULT VALUES-
|
--DEFAULT VALUES-
|
||||||
|
|
@ -34,9 +35,9 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
||||||
|
|
@ -66,6 +67,79 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
-- Will hold a part the highlighter will be attached to. This will be moved where the mouse is.
|
-- Will hold a part the highlighter will be attached to. This will be moved where the mouse is.
|
||||||
highlighter.selectionPart = nil
|
highlighter.selectionPart = nil
|
||||||
|
|
||||||
|
-- Create the part that the highlighter will be attached to.
|
||||||
|
highlighter.selectionPart = New "Part" {
|
||||||
|
Name = "SelectionPart",
|
||||||
|
Archivable = false,
|
||||||
|
Transparency = 1,
|
||||||
|
Anchored = true,
|
||||||
|
Locked = true,
|
||||||
|
CanCollide = false,
|
||||||
|
FormFactor = Enum.FormFactor.Custom,
|
||||||
|
}
|
||||||
|
|
||||||
|
highlighter.selectionBox = New "SelectionBox" {
|
||||||
|
Archivable = false,
|
||||||
|
Color = mouseHighlightColor,
|
||||||
|
Adornee = highlighter.selectionPart,
|
||||||
|
}
|
||||||
|
mouse2.TargetFilter = highlighter.selectionPart
|
||||||
|
setmetatable(highlighter, MouseHighlighter)
|
||||||
|
|
||||||
|
-- Update where the highlighter is displayed.
|
||||||
|
-- position - Where to display the highlighter, in world space.
|
||||||
|
function UpdatePosition(position)
|
||||||
|
if not position then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not mouse2.Target then
|
||||||
|
highlighter.selectionBox.Parent = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE:
|
||||||
|
-- Change this gui to be the one you want to use.
|
||||||
|
highlighter.selectionBox.Parent = CoreGui
|
||||||
|
|
||||||
|
local vectorPos = Vector3.new(position.x, position.y, position.z)
|
||||||
|
local cellPos = WorldToCellPreferSolid(c, vectorPos)
|
||||||
|
|
||||||
|
local regionToSelect
|
||||||
|
|
||||||
|
local lowVec = CellCenterToWorld(c, cellPos.x, cellPos.y - 1, cellPos.z)
|
||||||
|
local highVec =
|
||||||
|
CellCenterToWorld(c, cellPos.x, cellPos.y + 1, cellPos.z)
|
||||||
|
regionToSelect = Region3.new(lowVec, highVec)
|
||||||
|
|
||||||
|
highlighter.selectionPart.Size = regionToSelect.Size
|
||||||
|
- Vector3.new(-4, 4, -4)
|
||||||
|
highlighter.selectionPart.CFrame = regionToSelect.CFrame
|
||||||
|
|
||||||
|
if not (highlighter.OnClicked and highlighter.mouseDown) then
|
||||||
|
return
|
||||||
|
elseif not highlighter.lastUsedPoint then
|
||||||
|
highlighter.lastUsedPoint = WorldToCellPreferSolid(
|
||||||
|
c,
|
||||||
|
Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
cellPos = WorldToCellPreferSolid(
|
||||||
|
c,
|
||||||
|
Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z)
|
||||||
|
)
|
||||||
|
|
||||||
|
-- holdChange = cellPos - highlighter.lastUsedPoint -- ?
|
||||||
|
|
||||||
|
-- Require terrain.
|
||||||
|
if 0 == GetCell(c, cellPos.X, cellPos.Y, cellPos.Z).Value then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
highlighter.lastUsedPoint = cellPos
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Function to call when the mouse has moved. Updates where to display the highlighter.
|
-- Function to call when the mouse has moved. Updates where to display the highlighter.
|
||||||
local function MouseMoved()
|
local function MouseMoved()
|
||||||
if on then
|
if on then
|
||||||
|
|
@ -85,77 +159,6 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
highlighter.mouseDown = false
|
highlighter.mouseDown = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Create the part that the highlighter will be attached to.
|
|
||||||
highlighter.selectionPart = Instance.new "Part"
|
|
||||||
highlighter.selectionPart.Name = "SelectionPart"
|
|
||||||
highlighter.selectionPart.Archivable = false
|
|
||||||
highlighter.selectionPart.Transparency = 1
|
|
||||||
highlighter.selectionPart.Anchored = true
|
|
||||||
highlighter.selectionPart.Locked = true
|
|
||||||
highlighter.selectionPart.CanCollide = false
|
|
||||||
highlighter.selectionPart.FormFactor = Enum.FormFactor.Custom
|
|
||||||
|
|
||||||
highlighter.selectionBox = Instance.new "SelectionBox"
|
|
||||||
highlighter.selectionBox.Archivable = false
|
|
||||||
highlighter.selectionBox.Color = mouseHighlightColor
|
|
||||||
highlighter.selectionBox.Adornee = highlighter.selectionPart
|
|
||||||
mouse2.TargetFilter = highlighter.selectionPart
|
|
||||||
setmetatable(highlighter, MouseHighlighter)
|
|
||||||
|
|
||||||
-- Update where the highlighter is displayed.
|
|
||||||
-- position - Where to display the highlighter, in world space.
|
|
||||||
function UpdatePosition(position)
|
|
||||||
if not position then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not mouse2.Target then
|
|
||||||
highlighter.selectionBox.Parent = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- NOTE:
|
|
||||||
-- Change this gui to be the one you want to use.
|
|
||||||
highlighter.selectionBox.Parent = game:GetService "CoreGui"
|
|
||||||
|
|
||||||
local vectorPos = Vector3.new(position.x, position.y, position.z)
|
|
||||||
local cellPos = WorldToCellPreferSolid(c, vectorPos)
|
|
||||||
|
|
||||||
local regionToSelect
|
|
||||||
|
|
||||||
local lowVec = CellCenterToWorld(c, cellPos.x, cellPos.y - 1, cellPos.z)
|
|
||||||
local highVec =
|
|
||||||
CellCenterToWorld(c, cellPos.x, cellPos.y + 1, cellPos.z)
|
|
||||||
regionToSelect = Region3.new(lowVec, highVec)
|
|
||||||
|
|
||||||
highlighter.selectionPart.Size = regionToSelect.Size
|
|
||||||
- Vector3.new(-4, 4, -4)
|
|
||||||
highlighter.selectionPart.CFrame = regionToSelect.CFrame
|
|
||||||
|
|
||||||
if nil ~= highlighter.OnClicked and highlighter.mouseDown then
|
|
||||||
if nil == highlighter.lastUsedPoint then
|
|
||||||
highlighter.lastUsedPoint = WorldToCellPreferSolid(
|
|
||||||
c,
|
|
||||||
Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z)
|
|
||||||
)
|
|
||||||
else
|
|
||||||
cellPos = WorldToCellPreferSolid(
|
|
||||||
c,
|
|
||||||
Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z)
|
|
||||||
)
|
|
||||||
|
|
||||||
holdChange = cellPos - highlighter.lastUsedPoint
|
|
||||||
|
|
||||||
-- Require terrain.
|
|
||||||
if 0 == GetCell(c, cellPos.X, cellPos.Y, cellPos.Z).Value then
|
|
||||||
return
|
|
||||||
else
|
|
||||||
highlighter.lastUsedPoint = cellPos
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return highlighter
|
return highlighter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -176,9 +179,10 @@ local mouseHighlighter = MouseHighlighter.Create(mouse)
|
||||||
--GUI-
|
--GUI-
|
||||||
------
|
------
|
||||||
--screengui
|
--screengui
|
||||||
local g = Instance.new "ScreenGui"
|
local g = New "ScreenGui" {
|
||||||
g.Name = "RemoverGui"
|
Name = "RemoverGui",
|
||||||
g.Parent = game:GetService "CoreGui"
|
Parent = CoreGui,
|
||||||
|
}
|
||||||
|
|
||||||
-- UI gui load. Required for sliders.
|
-- UI gui load. Required for sliders.
|
||||||
local RbxGui = LoadLibrary "RbxGui"
|
local RbxGui = LoadLibrary "RbxGui"
|
||||||
|
|
@ -202,20 +206,23 @@ end)
|
||||||
|
|
||||||
removerHelpFrame.Size = UDim2.new(0, 160, 0, 60)
|
removerHelpFrame.Size = UDim2.new(0, 160, 0, 60)
|
||||||
|
|
||||||
local removerHelpText = Instance.new "TextLabel"
|
local helpText = [[
|
||||||
removerHelpText.Name = "HelpText"
|
|
||||||
removerHelpText.Font = Enum.Font.ArialBold
|
|
||||||
removerHelpText.FontSize = Enum.FontSize.Size12
|
|
||||||
removerHelpText.TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255)
|
|
||||||
removerHelpText.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
removerHelpText.TextYAlignment = Enum.TextYAlignment.Top
|
|
||||||
removerHelpText.Position = UDim2.new(0, 4, 0, 4)
|
|
||||||
removerHelpText.Size = UDim2.new(1, -8, 0, 177)
|
|
||||||
removerHelpText.BackgroundTransparency = 1
|
|
||||||
removerHelpText.TextWrap = true
|
|
||||||
removerHelpText.Text = [[
|
|
||||||
Clicking terrain removes a single block at the location clicked (shown with red highlight).]]
|
Clicking terrain removes a single block at the location clicked (shown with red highlight).]]
|
||||||
removerHelpText.Parent = removerHelpFrame
|
|
||||||
|
New "TextLabel" {
|
||||||
|
Name = "HelpText",
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size12,
|
||||||
|
TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255),
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
|
Position = UDim2.new(0, 4, 0, 4),
|
||||||
|
Size = UDim2.new(1, -8, 0, 177),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextWrapped = true,
|
||||||
|
Text = helpText,
|
||||||
|
Parent = removerHelpFrame,
|
||||||
|
}
|
||||||
|
|
||||||
CreateStandardLabel(
|
CreateStandardLabel(
|
||||||
"removeText",
|
"removeText",
|
||||||
|
|
@ -227,32 +234,33 @@ CreateStandardLabel(
|
||||||
|
|
||||||
-- Function to connect to the mouse button 1 down event. This is what will run when the user clicks.
|
-- Function to connect to the mouse button 1 down event. This is what will run when the user clicks.
|
||||||
-- mouse - Mouse data.
|
-- mouse - Mouse data.
|
||||||
function onClicked()
|
local function onClicked()
|
||||||
if on then
|
if not on then
|
||||||
local cellPos = WorldToCellPreferSolid(
|
return
|
||||||
|
end
|
||||||
|
local cellPos = WorldToCellPreferSolid(
|
||||||
|
c,
|
||||||
|
Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z)
|
||||||
|
)
|
||||||
|
local x = cellPos.x
|
||||||
|
local y = cellPos.y
|
||||||
|
local z = cellPos.z
|
||||||
|
|
||||||
|
SetCell(c, x, y, z, 0, 0, 0)
|
||||||
|
|
||||||
|
-- Mark undo point.
|
||||||
|
ChangeHistoryService:SetWaypoint "Remover"
|
||||||
|
|
||||||
|
UpdatePosition(mouse.Hit)
|
||||||
|
|
||||||
|
if properties.autoWedgeEnabled then
|
||||||
|
AutoWedge(
|
||||||
c,
|
c,
|
||||||
Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z)
|
Region3int16.new(
|
||||||
)
|
Vector3int16.new(x - 1, y - 1, z - 1),
|
||||||
local x = cellPos.x
|
Vector3int16.new(x + 1, y + 1, z + 1)
|
||||||
local y = cellPos.y
|
|
||||||
local z = cellPos.z
|
|
||||||
|
|
||||||
SetCell(c, x, y, z, 0, 0, 0)
|
|
||||||
|
|
||||||
-- Mark undo point.
|
|
||||||
ChangeHistoryService:SetWaypoint "Remover"
|
|
||||||
|
|
||||||
UpdatePosition(mouse.Hit)
|
|
||||||
|
|
||||||
if properties.autoWedgeEnabled then
|
|
||||||
AutoWedge(
|
|
||||||
c,
|
|
||||||
Region3int16.new(
|
|
||||||
Vector3int16.new(x - 1, y - 1, z - 1),
|
|
||||||
Vector3int16.new(x + 1, y + 1, z + 1)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
end
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
||||||
local CoreGui = game:GetService "CoreGui"
|
local CoreGui = game:GetService "CoreGui"
|
||||||
|
|
||||||
local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
||||||
|
local New = require("../Modules/New").New
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
--PLUGIN SETUP-
|
--PLUGIN SETUP-
|
||||||
|
|
@ -34,9 +35,9 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local SetWaterCell = c.SetWaterCell
|
local SetWaterCell = c.SetWaterCell
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
|
|
@ -73,7 +74,7 @@ local mouseHighlightColor = BrickColor.new "Lime green"
|
||||||
-- success - Value is true if there was a plane intersection, false if not.
|
-- success - Value is true if there was a plane intersection, false if not.
|
||||||
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
||||||
local function PlaneIntersection(vectorPos)
|
local function PlaneIntersection(vectorPos)
|
||||||
local currCamera = game.Workspace.CurrentCamera
|
local currCamera = workspace.CurrentCamera
|
||||||
local startPos = Vector3.new(
|
local startPos = Vector3.new(
|
||||||
currCamera.CoordinateFrame.p.X,
|
currCamera.CoordinateFrame.p.X,
|
||||||
currCamera.CoordinateFrame.p.Y,
|
currCamera.CoordinateFrame.p.Y,
|
||||||
|
|
@ -190,19 +191,20 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Create the part that the highlighter will be attached to.
|
-- Create the part that the highlighter will be attached to.
|
||||||
highlighter.selectionPart = Instance.new "Part"
|
highlighter.selectionPart = New "Part" {
|
||||||
highlighter.selectionPart.Name = "SelectionPart"
|
Name = "SelectionPart",
|
||||||
highlighter.selectionPart.Archivable = false
|
Archivable = false,
|
||||||
highlighter.selectionPart.Transparency = 1
|
Transparency = 1,
|
||||||
highlighter.selectionPart.Anchored = true
|
Anchored = true,
|
||||||
highlighter.selectionPart.Locked = true
|
Locked = true,
|
||||||
highlighter.selectionPart.CanCollide = false
|
CanCollide = false,
|
||||||
highlighter.selectionPart.FormFactor = Enum.FormFactor.Custom
|
FormFactor = Enum.FormFactor.Custom,
|
||||||
|
}
|
||||||
highlighter.selectionBox = Instance.new "SelectionBox"
|
highlighter.selectionBox = New "SelectionBox" {
|
||||||
highlighter.selectionBox.Archivable = false
|
Archivable = false,
|
||||||
highlighter.selectionBox.Color = mouseHighlightColor
|
Color = mouseHighlightColor,
|
||||||
highlighter.selectionBox.Adornee = highlighter.selectionPart
|
Adornee = highlighter.selectionPart,
|
||||||
|
}
|
||||||
mouseH.TargetFilter = highlighter.selectionPart
|
mouseH.TargetFilter = highlighter.selectionPart
|
||||||
setmetatable(highlighter, MouseHighlighter)
|
setmetatable(highlighter, MouseHighlighter)
|
||||||
|
|
||||||
|
|
@ -292,18 +294,7 @@ end)
|
||||||
|
|
||||||
elevationHelpFrame.Size = UDim2.new(0, 300, 0, 130)
|
elevationHelpFrame.Size = UDim2.new(0, 300, 0, 130)
|
||||||
|
|
||||||
local elevationHelpText = Instance.new "TextLabel"
|
local helpText = [[
|
||||||
elevationHelpText.Name = "HelpText"
|
|
||||||
elevationHelpText.Font = Enum.Font.ArialBold
|
|
||||||
elevationHelpText.FontSize = Enum.FontSize.Size12
|
|
||||||
elevationHelpText.TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255)
|
|
||||||
elevationHelpText.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
elevationHelpText.TextYAlignment = Enum.TextYAlignment.Top
|
|
||||||
elevationHelpText.Position = UDim2.new(0, 4, 0, 4)
|
|
||||||
elevationHelpText.Size = UDim2.new(1, -8, 0, 177)
|
|
||||||
elevationHelpText.BackgroundTransparency = 1
|
|
||||||
elevationHelpText.TextWrap = true
|
|
||||||
elevationHelpText.Text = [[
|
|
||||||
Use to drag terrain up or down. Hold the left mouse button down and drag the mouse up or down to create a mountain or valley.
|
Use to drag terrain up or down. Hold the left mouse button down and drag the mouse up or down to create a mountain or valley.
|
||||||
|
|
||||||
Radius:
|
Radius:
|
||||||
|
|
@ -311,7 +302,21 @@ The larger it is, the wider the top of the elevation will be.
|
||||||
|
|
||||||
Slope:
|
Slope:
|
||||||
The larger it is, the steeper the slope.]]
|
The larger it is, the steeper the slope.]]
|
||||||
elevationHelpText.Parent = elevationHelpFrame
|
|
||||||
|
New "TextLabel" {
|
||||||
|
Name = "HelpText",
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size12,
|
||||||
|
TextColor3 = Color3.new(227 / 255, 227 / 255, 227 / 255),
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
|
Position = UDim2.new(0, 4, 0, 4),
|
||||||
|
Size = UDim2.new(1, -8, 0, 177),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextWrapped = true,
|
||||||
|
Text = helpText,
|
||||||
|
Parent = elevationHelpFrame,
|
||||||
|
}
|
||||||
|
|
||||||
-- Slider for controlling radius.
|
-- Slider for controlling radius.
|
||||||
local radiusLabel = CreateStandardLabel(
|
local radiusLabel = CreateStandardLabel(
|
||||||
|
|
@ -418,10 +423,14 @@ local height
|
||||||
local oldheightmap = {}
|
local oldheightmap = {}
|
||||||
local heightmap = {}
|
local heightmap = {}
|
||||||
|
|
||||||
--elevates terrain at point (x, y, z) in cluster c
|
local function dist(x1, y1, x2, y2)
|
||||||
--within radius r1 from x, z the elevation should become y + d
|
return math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))
|
||||||
--from radius r1 to r2 the elevation should be a gradient
|
end
|
||||||
function elevate(x, y, z, r1, r2, d, range)
|
|
||||||
|
-- elevates terrain at point (x, y, z) in cluster c
|
||||||
|
-- within radius r1 from x, z the elevation should become y + d
|
||||||
|
-- from radius r1 to r2 the elevation should be a gradient
|
||||||
|
local function elevate(x, y, z, r1, r2, d, range)
|
||||||
for i = x - (range + 2), x + (range + 2) do
|
for i = x - (range + 2), x + (range + 2) do
|
||||||
if oldheightmap[i] == nil then
|
if oldheightmap[i] == nil then
|
||||||
oldheightmap[i] = {}
|
oldheightmap[i] = {}
|
||||||
|
|
@ -522,10 +531,6 @@ function elevate(x, y, z, r1, r2, d, range)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function dist(x1, y1, x2, y2)
|
|
||||||
return math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function dist3d(x1, y1, z1, x2, y2, z2)
|
-- function dist3d(x1, y1, z1, x2, y2, z2)
|
||||||
-- return math.sqrt(math.pow(dist(x1, z1, x2, z2), 2) + math.pow(math.abs(y2 - y1) * 100 / d, 2))
|
-- return math.sqrt(math.pow(dist(x1, z1, x2, z2), 2) + math.pow(math.abs(y2 - y1) * 100 / d, 2))
|
||||||
-- end
|
-- end
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ end
|
||||||
|
|
||||||
local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
||||||
local CoreGui = game:GetService "CoreGui"
|
local CoreGui = game:GetService "CoreGui"
|
||||||
|
local New = require("../Modules/New").New
|
||||||
|
|
||||||
-- local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
-- local CreateStandardLabel = require "../Modules/Terrain/CreateStandardLabel"
|
||||||
|
|
||||||
|
|
@ -28,10 +29,10 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-- Local function definitions
|
-- Local function definitions
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
local SetCells = c.SetCells
|
local SetCells = c.SetCells
|
||||||
local AutowedgeCells = c.AutowedgeCells
|
local AutowedgeCells = c.AutowedgeCells
|
||||||
|
|
@ -75,21 +76,31 @@ end)
|
||||||
mouse.Move:connect(function()
|
mouse.Move:connect(function()
|
||||||
mouseMoved()
|
mouseMoved()
|
||||||
end)
|
end)
|
||||||
local selectionPart = Instance.new "Part"
|
local selectionPart = New "Part" {
|
||||||
selectionPart.Name = "SelectionPart"
|
Name = "SelectionPart",
|
||||||
selectionPart.Archivable = false
|
Archivable = false,
|
||||||
selectionPart.Transparency = 1
|
Transparency = 1,
|
||||||
selectionPart.Anchored = true
|
Anchored = true,
|
||||||
selectionPart.Locked = true
|
Locked = true,
|
||||||
selectionPart.CanCollide = false
|
CanCollide = false,
|
||||||
selectionPart.FormFactor = Enum.FormFactor.Custom
|
FormFactor = Enum.FormFactor.Custom,
|
||||||
|
}
|
||||||
|
|
||||||
local selectionBox = Instance.new "SelectionBox"
|
local selectionBox = New "SelectionBox" {
|
||||||
selectionBox.Archivable = false
|
Archivable = false,
|
||||||
selectionBox.Color = BrickColor.new "Lime green"
|
Color = BrickColor.new "Lime green",
|
||||||
selectionBox.Adornee = selectionPart
|
Adornee = selectionPart,
|
||||||
|
}
|
||||||
mouse.TargetFilter = selectionPart
|
mouse.TargetFilter = selectionPart
|
||||||
|
|
||||||
|
function disablePreview()
|
||||||
|
selectionBox.Parent = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function enablePreview()
|
||||||
|
selectionBox.Parent = workspace
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
--FUNCTION DEFINITIONS-
|
--FUNCTION DEFINITIONS-
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
@ -113,7 +124,7 @@ function findLowestEmptyCell(x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- finds the lowest cell that is not filled in the radius that is currently specified
|
-- finds the lowest cell that is not filled in the radius that is currently specified
|
||||||
function findLowPoint(x, y, z)
|
local function findLowPoint(x, y, z)
|
||||||
local lowestPoint = maxYExtents + 1
|
local lowestPoint = maxYExtents + 1
|
||||||
for i = -radius, radius do
|
for i = -radius, radius do
|
||||||
local zPos = z + i
|
local zPos = z + i
|
||||||
|
|
@ -131,8 +142,40 @@ function findLowPoint(x, y, z)
|
||||||
return lowestPoint
|
return lowestPoint
|
||||||
end
|
end
|
||||||
|
|
||||||
--brushes terrain at point (x, y, z) in cluster c
|
-- Do a line/plane intersection. The line starts at the camera. The plane is at y == 0, normal(0, 1, 0)
|
||||||
function brush(x, y, z)
|
--
|
||||||
|
-- vectorPos - End point of the line.
|
||||||
|
--
|
||||||
|
-- Return:
|
||||||
|
-- success - Value is true if there was a plane intersection, false if not.
|
||||||
|
-- intersection - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
||||||
|
local function PlaneIntersection(vectorPos)
|
||||||
|
local currCamera = workspace.CurrentCamera
|
||||||
|
local startPos = Vector3.new(
|
||||||
|
currCamera.CoordinateFrame.p.X,
|
||||||
|
currCamera.CoordinateFrame.p.Y,
|
||||||
|
currCamera.CoordinateFrame.p.Z
|
||||||
|
)
|
||||||
|
local endPos = Vector3.new(vectorPos.X, vectorPos.Y, vectorPos.Z)
|
||||||
|
local normal = Vector3.new(0, 1, 0)
|
||||||
|
local p3 = Vector3.new(0, 0, 0)
|
||||||
|
local startEndDot = normal:Dot(endPos - startPos)
|
||||||
|
local cellPos = vectorPos
|
||||||
|
local success = false
|
||||||
|
if startEndDot ~= 0 then
|
||||||
|
local t = normal:Dot(p3 - startPos) / startEndDot
|
||||||
|
if t >= 0 and t <= 1 then
|
||||||
|
local intersection = ((endPos - startPos) * t) + startPos
|
||||||
|
cellPos = c:WorldToCell(intersection)
|
||||||
|
success = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return success, cellPos
|
||||||
|
end
|
||||||
|
|
||||||
|
-- brushes terrain at point (x, y, z) in cluster c
|
||||||
|
local function brush(x, y, z)
|
||||||
if depth == 0 then
|
if depth == 0 then
|
||||||
return
|
return
|
||||||
elseif depth > 0 then
|
elseif depth > 0 then
|
||||||
|
|
@ -160,14 +203,6 @@ function brush(x, y, z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function disablePreview()
|
|
||||||
selectionBox.Parent = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function enablePreview()
|
|
||||||
selectionBox.Parent = game.Workspace
|
|
||||||
end
|
|
||||||
|
|
||||||
function updatePreviewSelection(position)
|
function updatePreviewSelection(position)
|
||||||
if not position then
|
if not position then
|
||||||
return
|
return
|
||||||
|
|
@ -257,7 +292,7 @@ function doFillCells(position, mouseDrag, needsCellPos)
|
||||||
local timeBetweenFills = tick() - lastCellFillTime
|
local timeBetweenFills = tick() - lastCellFillTime
|
||||||
local totalDragPixels = math.abs(mouseDrag.x) + math.abs(mouseDrag.y)
|
local totalDragPixels = math.abs(mouseDrag.x) + math.abs(mouseDrag.y)
|
||||||
local editDistance = (
|
local editDistance = (
|
||||||
game.Workspace.CurrentCamera.CoordinateFrame.p
|
workspace.CurrentCamera.CoordinateFrame.p
|
||||||
- Vector3.new(position.x, position.y, position.z)
|
- Vector3.new(position.x, position.y, position.z)
|
||||||
).magnitude
|
).magnitude
|
||||||
|
|
||||||
|
|
@ -322,38 +357,6 @@ function mouseMoved()
|
||||||
updatePreviewSelection(mouse.Hit)
|
updatePreviewSelection(mouse.Hit)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Do a line/plane intersection. The line starts at the camera. The plane is at y == 0, normal(0, 1, 0)
|
|
||||||
--
|
|
||||||
-- vectorPos - End point of the line.
|
|
||||||
--
|
|
||||||
-- Return:
|
|
||||||
-- success - Value is true if there was a plane intersection, false if not.
|
|
||||||
-- intersection - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
|
||||||
function PlaneIntersection(vectorPos)
|
|
||||||
local currCamera = game.Workspace.CurrentCamera
|
|
||||||
local startPos = Vector3.new(
|
|
||||||
currCamera.CoordinateFrame.p.X,
|
|
||||||
currCamera.CoordinateFrame.p.Y,
|
|
||||||
currCamera.CoordinateFrame.p.Z
|
|
||||||
)
|
|
||||||
local endPos = Vector3.new(vectorPos.X, vectorPos.Y, vectorPos.Z)
|
|
||||||
local normal = Vector3.new(0, 1, 0)
|
|
||||||
local p3 = Vector3.new(0, 0, 0)
|
|
||||||
local startEndDot = normal:Dot(endPos - startPos)
|
|
||||||
local cellPos = vectorPos
|
|
||||||
local success = false
|
|
||||||
if startEndDot ~= 0 then
|
|
||||||
local t = normal:Dot(p3 - startPos) / startEndDot
|
|
||||||
if t >= 0 and t <= 1 then
|
|
||||||
local intersection = ((endPos - startPos) * t) + startPos
|
|
||||||
cellPos = c:WorldToCell(intersection)
|
|
||||||
success = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return success, cellPos
|
|
||||||
end
|
|
||||||
|
|
||||||
function buttonDown()
|
function buttonDown()
|
||||||
if on then
|
if on then
|
||||||
local firstCellPos = WorldToCellPreferSolid(
|
local firstCellPos = WorldToCellPreferSolid(
|
||||||
|
|
@ -372,11 +375,10 @@ function buttonDown()
|
||||||
Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z)
|
Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z)
|
||||||
)
|
)
|
||||||
if not success then
|
if not success then
|
||||||
if mouse.Target then
|
if not mouse.Target then
|
||||||
firstCellPos = solidCell
|
|
||||||
else
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
firstCellPos = solidCell
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -515,9 +517,10 @@ end
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
--screengui
|
--screengui
|
||||||
local g = Instance.new "ScreenGui"
|
local g = New "ScreenGui" {
|
||||||
g.Name = "TerrainBrushGui"
|
Name = "TerrainBrushGui",
|
||||||
g.Parent = CoreGui
|
Parent = CoreGui,
|
||||||
|
}
|
||||||
|
|
||||||
local elevationFrame, elevationHelpFrame, elevationCloseEvent
|
local elevationFrame, elevationHelpFrame, elevationCloseEvent
|
||||||
brushDragBar, elevationFrame, elevationHelpFrame, elevationCloseEvent =
|
brushDragBar, elevationFrame, elevationHelpFrame, elevationCloseEvent =
|
||||||
|
|
@ -534,16 +537,8 @@ elevationCloseEvent.Event:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
elevationHelpFrame.Size = UDim2.new(0, 200, 0, 210)
|
elevationHelpFrame.Size = UDim2.new(0, 200, 0, 210)
|
||||||
local helpText = Instance.new "TextLabel"
|
|
||||||
helpText.Font = Enum.Font.ArialBold
|
local helpText =
|
||||||
helpText.FontSize = Enum.FontSize.Size12
|
|
||||||
helpText.TextColor3 = Color3.new(1, 1, 1)
|
|
||||||
helpText.BackgroundTransparency = 1
|
|
||||||
helpText.TextWrap = true
|
|
||||||
helpText.Size = UDim2.new(1, -10, 1, -10)
|
|
||||||
helpText.Position = UDim2.new(0, 5, 0, 5)
|
|
||||||
helpText.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
helpText.Text =
|
|
||||||
[[Drag the mouse by holding the left mouse button to either create or destroy terrain defined by the selection box.
|
[[Drag the mouse by holding the left mouse button to either create or destroy terrain defined by the selection box.
|
||||||
|
|
||||||
Radius:
|
Radius:
|
||||||
|
|
@ -552,21 +547,34 @@ Half of the width of the selection box to be used.
|
||||||
Height:
|
Height:
|
||||||
How tall to make terrain from the mouse location. If this value is negative, the brush will remove terrain instead of creating terrain (indicated by the red selection box).
|
How tall to make terrain from the mouse location. If this value is negative, the brush will remove terrain instead of creating terrain (indicated by the red selection box).
|
||||||
]]
|
]]
|
||||||
helpText.Parent = elevationHelpFrame
|
|
||||||
|
|
||||||
--current radius display label
|
New "TextLabel" {
|
||||||
local radl = Instance.new "TextLabel"
|
Font = Enum.Font.ArialBold,
|
||||||
radl.Position = UDim2.new(0, 0, 0, 70)
|
FontSize = Enum.FontSize.Size12,
|
||||||
radl.Size = UDim2.new(1, 0, 0, 14)
|
TextColor3 = Color3.new(1, 1, 1),
|
||||||
radl.Text = ""
|
BackgroundTransparency = 1,
|
||||||
radl.BackgroundColor3 = Color3.new(0.4, 0.4, 0.4)
|
TextWrapped = true,
|
||||||
radl.TextColor3 = Color3.new(0.95, 0.95, 0.95)
|
Size = UDim2.new(1, -10, 1, -10),
|
||||||
radl.Font = Enum.Font.ArialBold
|
Position = UDim2.new(0, 5, 0, 5),
|
||||||
radl.FontSize = Enum.FontSize.Size14
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
radl.TextXAlignment = Enum.TextXAlignment.Left
|
Text = helpText,
|
||||||
radl.BorderColor3 = Color3.new(0, 0, 0)
|
Parent = elevationHelpFrame,
|
||||||
radl.BackgroundTransparency = 1
|
}
|
||||||
radl.Parent = elevationFrame
|
|
||||||
|
-- current radius display label
|
||||||
|
local radl = New "TextLabel" {
|
||||||
|
Position = UDim2.new(0, 0, 0, 70),
|
||||||
|
Size = UDim2.new(1, 0, 0, 14),
|
||||||
|
Text = "",
|
||||||
|
BackgroundColor3 = Color3.new(0.4, 0.4, 0.4),
|
||||||
|
TextColor3 = Color3.new(0.95, 0.95, 0.95),
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size14,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
BorderColor3 = Color3.new(0, 0, 0),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
Parent = elevationFrame,
|
||||||
|
}
|
||||||
|
|
||||||
--radius slider
|
--radius slider
|
||||||
local radSliderGui, radSliderPosition =
|
local radSliderGui, radSliderPosition =
|
||||||
|
|
@ -581,18 +589,19 @@ end)
|
||||||
radSliderPosition.Value = radius - 1
|
radSliderPosition.Value = radius - 1
|
||||||
|
|
||||||
--current depth factor display label
|
--current depth factor display label
|
||||||
local dfl = Instance.new "TextLabel"
|
local dfl = New "TextLabel" {
|
||||||
dfl.Position = UDim2.new(0, 0, 0, 110)
|
Position = UDim2.new(0, 0, 0, 110),
|
||||||
dfl.Size = UDim2.new(1, 0, 0, 14)
|
Size = UDim2.new(1, 0, 0, 14),
|
||||||
dfl.Text = ""
|
Text = "",
|
||||||
dfl.BackgroundColor3 = Color3.new(0.4, 0.4, 0.4)
|
BackgroundColor3 = Color3.new(0.4, 0.4, 0.4),
|
||||||
dfl.TextColor3 = Color3.new(0.95, 0.95, 0.95)
|
TextColor3 = Color3.new(0.95, 0.95, 0.95),
|
||||||
dfl.Font = Enum.Font.ArialBold
|
Font = Enum.Font.ArialBold,
|
||||||
dfl.FontSize = Enum.FontSize.Size14
|
FontSize = Enum.FontSize.Size14,
|
||||||
dfl.BorderColor3 = Color3.new(0, 0, 0)
|
BorderColor3 = Color3.new(0, 0, 0),
|
||||||
dfl.TextXAlignment = Enum.TextXAlignment.Left
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
dfl.BackgroundTransparency = 1
|
BackgroundTransparency = 1,
|
||||||
dfl.Parent = elevationFrame
|
Parent = elevationFrame,
|
||||||
|
}
|
||||||
|
|
||||||
--depth factor slider
|
--depth factor slider
|
||||||
local addSliderGui, addSliderPosition =
|
local addSliderGui, addSliderPosition =
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-- Local function definitions
|
-- Local function definitions
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
||||||
|
|
@ -196,7 +196,7 @@ helpText.Font = Enum.Font.ArialBold
|
||||||
helpText.FontSize = Enum.FontSize.Size12
|
helpText.FontSize = Enum.FontSize.Size12
|
||||||
helpText.TextColor3 = Color3.new(1, 1, 1)
|
helpText.TextColor3 = Color3.new(1, 1, 1)
|
||||||
helpText.BackgroundTransparency = 1
|
helpText.BackgroundTransparency = 1
|
||||||
helpText.TextWrap = true
|
helpText.TextWrapped = true
|
||||||
helpText.Size = UDim2.new(1, -10, 1, -10)
|
helpText.Size = UDim2.new(1, -10, 1, -10)
|
||||||
helpText.Position = UDim2.new(0, 5, 0, 5)
|
helpText.Position = UDim2.new(0, 5, 0, 5)
|
||||||
helpText.TextXAlignment = Enum.TextXAlignment.Left
|
helpText.TextXAlignment = Enum.TextXAlignment.Left
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-- Local function definitions
|
-- Local function definitions
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local GetCell = c.GetCell
|
local GetCell = c.GetCell
|
||||||
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
||||||
local WorldToCellPreferEmpty = c.WorldToCellPreferEmpty
|
local WorldToCellPreferEmpty = c.WorldToCellPreferEmpty
|
||||||
|
|
@ -195,7 +195,7 @@ end
|
||||||
-- success - Value is true if there was a plane intersection, false if not.
|
-- success - Value is true if there was a plane intersection, false if not.
|
||||||
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
-- cellPos - Value is the terrain cell intersection point if there is one, vectorPos if there isn't.
|
||||||
function PlaneIntersection(vectorPos)
|
function PlaneIntersection(vectorPos)
|
||||||
local currCamera = game.Workspace.CurrentCamera
|
local currCamera = workspace.CurrentCamera
|
||||||
local startPos = Vector3.new(
|
local startPos = Vector3.new(
|
||||||
currCamera.CoordinateFrame.p.X,
|
currCamera.CoordinateFrame.p.X,
|
||||||
currCamera.CoordinateFrame.p.Y,
|
currCamera.CoordinateFrame.p.Y,
|
||||||
|
|
@ -260,10 +260,8 @@ mouse.Button1Down:connect(function()
|
||||||
local celMat = GetCell(c, x, y, z)
|
local celMat = GetCell(c, x, y, z)
|
||||||
if celMat.Value > 0 then
|
if celMat.Value > 0 then
|
||||||
DefaultTerrainMaterial = celMat.Value
|
DefaultTerrainMaterial = celMat.Value
|
||||||
else
|
elseif 0 == DefaultTerrainMaterial then
|
||||||
if 0 == DefaultTerrainMaterial then
|
DefaultTerrainMaterial = 1
|
||||||
DefaultTerrainMaterial = 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif mode == 1 then
|
elseif mode == 1 then
|
||||||
x2 = x
|
x2 = x
|
||||||
|
|
@ -336,7 +334,7 @@ roadTextHelper.Size = UDim2.new(1, -8, 1, -8)
|
||||||
roadTextHelper.Position = UDim2.new(0, 4, 0, 4)
|
roadTextHelper.Position = UDim2.new(0, 4, 0, 4)
|
||||||
roadTextHelper.TextXAlignment = Enum.TextXAlignment.Left
|
roadTextHelper.TextXAlignment = Enum.TextXAlignment.Left
|
||||||
roadTextHelper.TextYAlignment = Enum.TextYAlignment.Top
|
roadTextHelper.TextYAlignment = Enum.TextYAlignment.Top
|
||||||
roadTextHelper.TextWrap = true
|
roadTextHelper.TextWrapped = true
|
||||||
roadTextHelper.Parent = roadFrame
|
roadTextHelper.Parent = roadFrame
|
||||||
|
|
||||||
roadHelpFrame.Size = UDim2.new(0, 200, 0, 150)
|
roadHelpFrame.Size = UDim2.new(0, 200, 0, 150)
|
||||||
|
|
@ -345,7 +343,7 @@ helpText.Font = Enum.Font.ArialBold
|
||||||
helpText.FontSize = Enum.FontSize.Size12
|
helpText.FontSize = Enum.FontSize.Size12
|
||||||
helpText.TextColor3 = Color3.new(1, 1, 1)
|
helpText.TextColor3 = Color3.new(1, 1, 1)
|
||||||
helpText.BackgroundTransparency = 1
|
helpText.BackgroundTransparency = 1
|
||||||
helpText.TextWrap = true
|
helpText.TextWrapped = true
|
||||||
helpText.Size = UDim2.new(1, -10, 1, -10)
|
helpText.Size = UDim2.new(1, -10, 1, -10)
|
||||||
helpText.Position = UDim2.new(0, 5, 0, 5)
|
helpText.Position = UDim2.new(0, 5, 0, 5)
|
||||||
helpText.TextXAlignment = Enum.TextXAlignment.Left
|
helpText.TextXAlignment = Enum.TextXAlignment.Left
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ end
|
||||||
local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
local ChangeHistoryService = game:GetService "ChangeHistoryService"
|
||||||
local CoreGui = game:GetService "CoreGui"
|
local CoreGui = game:GetService "CoreGui"
|
||||||
|
|
||||||
|
local News = require "../Modules/New"
|
||||||
|
local New = News.New
|
||||||
|
local Hydrate = News.Hydrate
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
--PLUGIN SETUP-
|
--PLUGIN SETUP-
|
||||||
---------------
|
---------------
|
||||||
|
|
@ -41,12 +45,12 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
--LOCAL FUNCTION DEFINITIONS-
|
--LOCAL FUNCTION DEFINITIONS-
|
||||||
-----------------------------
|
-----------------------------
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
local SetCell = c.SetCell
|
local SetCell = c.SetCell
|
||||||
local SetWaterCell = c.SetWaterCell
|
local SetWaterCell = c.SetWaterCell
|
||||||
-- local GetWaterCell = c.GetWaterCell
|
-- local GetWaterCell = c.GetWaterCell
|
||||||
|
|
@ -568,14 +572,12 @@ local function setPositionDirectionality()
|
||||||
end
|
end
|
||||||
|
|
||||||
function mouseDown(mouseD)
|
function mouseDown(mouseD)
|
||||||
if not (on and mouseD.Target == game.Workspace.Terrain) then
|
if not (on and mouseD.Target == workspace.Terrain) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
dragging = true
|
dragging = true
|
||||||
if
|
if not (mouseD and mouseD.Hit and mouseD.Target == workspace.Terrain) then
|
||||||
not (mouseD and mouseD.Hit and mouseD.Target == game.Workspace.Terrain)
|
|
||||||
then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -605,42 +607,6 @@ function mouseUp(_)
|
||||||
lastCell = nil
|
lastCell = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function mouseMove(mouseM)
|
|
||||||
if not on then
|
|
||||||
return
|
|
||||||
elseif mouseM.Target == game.Workspace.Terrain then
|
|
||||||
if lastCell == WorldToCellPreferSolid(c, mouseM.Hit.p) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
updateSelection(mouseM)
|
|
||||||
local newCell = WorldToCellPreferSolid(c, mouseM.Hit.p)
|
|
||||||
|
|
||||||
if not dragging then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- local painting = true
|
|
||||||
paint(newCell)
|
|
||||||
if lastCell and newCell and (lastCell - newCell).magnitude > 1 then
|
|
||||||
paintBetweenPoints(lastCell, newCell)
|
|
||||||
end
|
|
||||||
lastLastCell = lastCell
|
|
||||||
lastCell = newCell
|
|
||||||
-- painting = false
|
|
||||||
else
|
|
||||||
destroySelection()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function destroySelection()
|
|
||||||
if currSelectionUpdate then
|
|
||||||
currSelectionUpdate = nil
|
|
||||||
end
|
|
||||||
if currSelectionDestroy then
|
|
||||||
currSelectionDestroy()
|
|
||||||
currSelectionDestroy = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function moveTowardsGoal(direction: string, currPos, goalPos, currCell)
|
local function moveTowardsGoal(direction: string, currPos, goalPos, currCell)
|
||||||
if currPos == goalPos then
|
if currPos == goalPos then
|
||||||
return currCell
|
return currCell
|
||||||
|
|
@ -676,7 +642,7 @@ local function interpolateOneDim(direction, currPos, goalPos, currCell)
|
||||||
return currCell
|
return currCell
|
||||||
end
|
end
|
||||||
|
|
||||||
function paintBetweenPoints(lastCellP, newCell)
|
local function paintBetweenPoints(lastCellP, newCell)
|
||||||
local currCell = lastCellP
|
local currCell = lastCellP
|
||||||
|
|
||||||
while
|
while
|
||||||
|
|
@ -690,6 +656,42 @@ function paintBetweenPoints(lastCellP, newCell)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function destroySelection()
|
||||||
|
if currSelectionUpdate then
|
||||||
|
currSelectionUpdate = nil
|
||||||
|
end
|
||||||
|
if currSelectionDestroy then
|
||||||
|
currSelectionDestroy()
|
||||||
|
currSelectionDestroy = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mouseMove(mouseM)
|
||||||
|
if not on then
|
||||||
|
return
|
||||||
|
elseif mouseM.Target == workspace.Terrain then
|
||||||
|
if lastCell == WorldToCellPreferSolid(c, mouseM.Hit.p) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
updateSelection(mouseM)
|
||||||
|
local newCell = WorldToCellPreferSolid(c, mouseM.Hit.p)
|
||||||
|
|
||||||
|
if not dragging then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- local painting = true
|
||||||
|
paint(newCell)
|
||||||
|
if lastCell and newCell and (lastCell - newCell).magnitude > 1 then
|
||||||
|
paintBetweenPoints(lastCell, newCell)
|
||||||
|
end
|
||||||
|
lastLastCell = lastCell
|
||||||
|
lastCell = newCell
|
||||||
|
-- painting = false
|
||||||
|
else
|
||||||
|
destroySelection()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function On()
|
function On()
|
||||||
if not c then
|
if not c then
|
||||||
return
|
return
|
||||||
|
|
@ -714,9 +716,10 @@ end
|
||||||
------
|
------
|
||||||
|
|
||||||
--screengui
|
--screengui
|
||||||
local g = Instance.new "ScreenGui"
|
local g = New "ScreenGui" {
|
||||||
g.Name = "MaterialPainterGui"
|
Name = "MaterialPainterGui",
|
||||||
g.Parent = CoreGui
|
Parent = CoreGui,
|
||||||
|
}
|
||||||
|
|
||||||
local containerFrame
|
local containerFrame
|
||||||
dragBar, containerFrame, helpFrame, closeEvent = RbxGui.CreatePluginFrame(
|
dragBar, containerFrame, helpFrame, closeEvent = RbxGui.CreatePluginFrame(
|
||||||
|
|
@ -738,20 +741,8 @@ end)
|
||||||
|
|
||||||
helpFrame.Size = UDim2.new(0, 200, 0, 250)
|
helpFrame.Size = UDim2.new(0, 200, 0, 250)
|
||||||
helpFrame.ZIndex = 3
|
helpFrame.ZIndex = 3
|
||||||
local textHelp = Instance.new "TextLabel"
|
|
||||||
textHelp.Name = "TextHelp"
|
local helpText =
|
||||||
textHelp.Font = Enum.Font.ArialBold
|
|
||||||
textHelp.FontSize = Enum.FontSize.Size12
|
|
||||||
textHelp.TextColor3 = Color3.new(1, 1, 1)
|
|
||||||
textHelp.Size = UDim2.new(1, -6, 1, -6)
|
|
||||||
textHelp.Position = UDim2.new(0, 3, 0, 3)
|
|
||||||
textHelp.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
textHelp.TextYAlignment = Enum.TextYAlignment.Top
|
|
||||||
textHelp.Position = UDim2.new(0, 4, 0, 4)
|
|
||||||
textHelp.BackgroundTransparency = 1
|
|
||||||
textHelp.TextWrap = true
|
|
||||||
textHelp.ZIndex = 4
|
|
||||||
textHelp.Text =
|
|
||||||
[[Changes existing terrain blocks to the specified material. Simply hold the mouse down and drag to 'paint' the terrain (only cells inside the selection box will be affected).
|
[[Changes existing terrain blocks to the specified material. Simply hold the mouse down and drag to 'paint' the terrain (only cells inside the selection box will be affected).
|
||||||
|
|
||||||
Size:
|
Size:
|
||||||
|
|
@ -762,53 +753,80 @@ The shape we paint terrain with inside of our selection box.
|
||||||
|
|
||||||
Material Selection:
|
Material Selection:
|
||||||
The terrain material we will paint.]]
|
The terrain material we will paint.]]
|
||||||
textHelp.Parent = helpFrame
|
|
||||||
|
New "TextLabel" {
|
||||||
|
Name = "TextHelp",
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size12,
|
||||||
|
TextColor3 = Color3.new(1, 1, 1),
|
||||||
|
Size = UDim2.new(1, -6, 1, -6),
|
||||||
|
-- Position = UDim2.new(0, 3, 0, 3), -- lellel new supremacy - Heliodex
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
|
Position = UDim2.new(0, 4, 0, 4),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextWrapped = true,
|
||||||
|
ZIndex = 4,
|
||||||
|
Text = helpText,
|
||||||
|
Parent = helpFrame,
|
||||||
|
}
|
||||||
|
|
||||||
closeEvent.Event:connect(function()
|
closeEvent.Event:connect(function()
|
||||||
Off()
|
Off()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
terrainSelectorGui, terrainSelected, forceTerrainSelection =
|
terrainSelectorGui, terrainSelected = RbxGui.CreateTerrainMaterialSelector(
|
||||||
RbxGui.CreateTerrainMaterialSelector(
|
UDim2.new(1, -10, 0, 184),
|
||||||
UDim2.new(1, -10, 0, 184),
|
UDim2.new(0, 5, 1, -190)
|
||||||
UDim2.new(0, 5, 1, -190)
|
)
|
||||||
)
|
Hydrate(terrainSelectorGui) {
|
||||||
terrainSelectorGui.Parent = containerFrame
|
BackgroundTransparency = 1,
|
||||||
terrainSelectorGui.BackgroundTransparency = 1
|
BorderSizePixel = 0,
|
||||||
terrainSelectorGui.BorderSizePixel = 0
|
Parent = containerFrame,
|
||||||
|
}
|
||||||
terrainSelected.Event:connect(function(newMaterial)
|
terrainSelected.Event:connect(function(newMaterial)
|
||||||
currentMaterial = newMaterial
|
currentMaterial = newMaterial
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Purpose:
|
-- Purpose:
|
||||||
-- Retrive the size text to display for a given radius, where 1 == 1 block and 2 == 3 blocks, etc.
|
-- Retrive the size text to display for a given radius, where 1 == 1 block and 2 == 3 blocks, etc.
|
||||||
function SizeText(radiusT)
|
local function SizeText(radiusT: number)
|
||||||
return "Size: " .. (((radiusT - 1) * 2) + 1)
|
return "Size: " .. (((radiusT - 1) * 2) + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function makeRadiusLabel()
|
||||||
|
return New "TextLabel" {
|
||||||
|
Size = UDim2.new(1, -3, 0, 14),
|
||||||
|
TextColor3 = Color3.new(0.95, 0.95, 0.95),
|
||||||
|
Font = Enum.Font.ArialBold,
|
||||||
|
FontSize = Enum.FontSize.Size14,
|
||||||
|
BorderColor3 = Color3.new(0, 0, 0),
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
--current radius display label
|
--current radius display label
|
||||||
radiusLabel = Instance.new "TextLabel"
|
radiusLabel = Hydrate(makeRadiusLabel()) {
|
||||||
radiusLabel.Name = "RadiusLabel"
|
Name = "RadiusLabel",
|
||||||
radiusLabel.Position = UDim2.new(0, 10, 0, 5)
|
Text = SizeText(radius),
|
||||||
radiusLabel.Size = UDim2.new(1, -3, 0, 14)
|
Position = UDim2.new(0, 10, 0, 5),
|
||||||
radiusLabel.Text = SizeText(radius)
|
Parent = containerFrame,
|
||||||
radiusLabel.TextColor3 = Color3.new(0.95, 0.95, 0.95)
|
}
|
||||||
radiusLabel.Font = Enum.Font.ArialBold
|
|
||||||
radiusLabel.FontSize = Enum.FontSize.Size14
|
|
||||||
radiusLabel.BorderColor3 = Color3.new(0, 0, 0)
|
|
||||||
radiusLabel.BackgroundTransparency = 1
|
|
||||||
radiusLabel.TextXAlignment = Enum.TextXAlignment.Left
|
|
||||||
radiusLabel.Parent = containerFrame
|
|
||||||
|
|
||||||
--radius slider
|
--radius slider
|
||||||
local radSliderGui, radSliderPosition =
|
local radSliderGui, radSliderPosition =
|
||||||
RbxGui.CreateSlider(6, 0, UDim2.new(0, 0, 0, 18))
|
RbxGui.CreateSlider(6, 0, UDim2.new(0, 0, 0, 18))
|
||||||
radSliderGui.Size = UDim2.new(1, -2, 0, 20)
|
Hydrate(radSliderGui) {
|
||||||
radSliderGui.Position = UDim2.new(0, 0, 0, 24)
|
Size = UDim2.new(1, -2, 0, 20),
|
||||||
radSliderGui.Parent = containerFrame
|
Position = UDim2.new(0, 0, 0, 24),
|
||||||
local radBar = radSliderGui:FindFirstChild "Bar"
|
Parent = containerFrame,
|
||||||
radBar.Size = UDim2.new(1, -20, 0, 5)
|
}
|
||||||
radBar.Position = UDim2.new(0, 10, 0.5, -3)
|
Hydrate(radSliderGui.Bar) {
|
||||||
|
Size = UDim2.new(1, -20, 0, 5),
|
||||||
|
Position = UDim2.new(0, 10, 0.5, -3),
|
||||||
|
}
|
||||||
|
|
||||||
radSliderPosition.Value = radius
|
radSliderPosition.Value = radius
|
||||||
radSliderPosition.Changed:connect(function()
|
radSliderPosition.Changed:connect(function()
|
||||||
radius = radSliderPosition.Value
|
radius = radSliderPosition.Value
|
||||||
|
|
@ -823,15 +841,18 @@ end
|
||||||
local brushDropDown, forceSelection =
|
local brushDropDown, forceSelection =
|
||||||
RbxGui.CreateDropDownMenu(brushTypes, brushTypeChanged)
|
RbxGui.CreateDropDownMenu(brushTypes, brushTypeChanged)
|
||||||
forceSelection "Square"
|
forceSelection "Square"
|
||||||
brushDropDown.Size = UDim2.new(1, -10, 0.01, 25)
|
|
||||||
brushDropDown.Position = UDim2.new(0, 5, 0, 65)
|
|
||||||
brushDropDown.Parent = containerFrame
|
|
||||||
|
|
||||||
local brushLabel = radiusLabel:Clone()
|
Hydrate(brushDropDown) {
|
||||||
brushLabel.Name = "BrushLabel"
|
Size = UDim2.new(1, -10, 0.01, 25),
|
||||||
brushLabel.Text = "Brush Type"
|
Position = UDim2.new(0, 5, 0, 65),
|
||||||
brushLabel.Position = UDim2.new(0, 10, 0, 50)
|
Parent = containerFrame,
|
||||||
brushLabel.Parent = containerFrame
|
}
|
||||||
|
Hydrate(makeRadiusLabel()) {
|
||||||
|
Name = "BrushLabel",
|
||||||
|
Text = "Brush Type",
|
||||||
|
Position = UDim2.new(0, 10, 0, 50),
|
||||||
|
Parent = containerFrame,
|
||||||
|
}
|
||||||
|
|
||||||
this.Deactivation:connect(function()
|
this.Deactivation:connect(function()
|
||||||
Off()
|
Off()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
--DEFAULT VALUES-
|
--DEFAULT VALUES-
|
||||||
|
|
@ -375,7 +375,7 @@ function createGui()
|
||||||
end
|
end
|
||||||
|
|
||||||
function On()
|
function On()
|
||||||
if not game.Workspace.Terrain then
|
if not workspace.Terrain then
|
||||||
return
|
return
|
||||||
elseif this then
|
elseif this then
|
||||||
this:Activate(true)
|
this:Activate(true)
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ toolbarbutton.Click:connect(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:WaitForChild "Workspace"
|
game:WaitForChild "Workspace"
|
||||||
game.Workspace:WaitForChild "Terrain"
|
workspace:WaitForChild "Terrain"
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
--LOCAL FUNCTION DEFINITIONS-
|
--LOCAL FUNCTION DEFINITIONS-
|
||||||
-----------------------------
|
-----------------------------
|
||||||
local c = game.Workspace.Terrain
|
local c = workspace.Terrain
|
||||||
-- local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
-- local WorldToCellPreferSolid = c.WorldToCellPreferSolid
|
||||||
local WorldToCellPreferEmpty = c.WorldToCellPreferEmpty
|
local WorldToCellPreferEmpty = c.WorldToCellPreferEmpty
|
||||||
local CellCenterToWorld = c.CellCenterToWorld
|
local CellCenterToWorld = c.CellCenterToWorld
|
||||||
|
|
@ -83,44 +83,32 @@ ContentProvider:Preload "http://banland.xyz/asset?id=82741829"
|
||||||
------------------------- OBJECT DEFINITIONS ---------------------
|
------------------------- OBJECT DEFINITIONS ---------------------
|
||||||
|
|
||||||
-- helper function for objects
|
-- helper function for objects
|
||||||
|
local colours = {
|
||||||
|
"Bright green",
|
||||||
|
"Bright yellow",
|
||||||
|
"Bright red",
|
||||||
|
"Sand red",
|
||||||
|
"Black",
|
||||||
|
"Dark stone grey",
|
||||||
|
"Sand blue",
|
||||||
|
"Deep orange",
|
||||||
|
"Dark orange",
|
||||||
|
"Reddish brown",
|
||||||
|
"Light orange",
|
||||||
|
"Light stone grey",
|
||||||
|
"Sand green",
|
||||||
|
"Medium stone grey",
|
||||||
|
"Really red",
|
||||||
|
"Really blue",
|
||||||
|
"Bright blue",
|
||||||
|
}
|
||||||
|
|
||||||
local function getClosestColorToTerrainMaterial(terrainValue)
|
local function getClosestColorToTerrainMaterial(terrainValue)
|
||||||
if terrainValue == 1 then
|
local val = BrickColor.new(colours[terrainValue])
|
||||||
return BrickColor.new "Bright green"
|
if val then
|
||||||
elseif terrainValue == 2 then
|
return val
|
||||||
return BrickColor.new "Bright yellow"
|
|
||||||
elseif terrainValue == 3 then
|
|
||||||
return BrickColor.new "Bright red"
|
|
||||||
elseif terrainValue == 4 then
|
|
||||||
return BrickColor.new "Sand red"
|
|
||||||
elseif terrainValue == 5 then
|
|
||||||
return BrickColor.new "Black"
|
|
||||||
elseif terrainValue == 6 then
|
|
||||||
return BrickColor.new "Dark stone grey"
|
|
||||||
elseif terrainValue == 7 then
|
|
||||||
return BrickColor.new "Sand blue"
|
|
||||||
elseif terrainValue == 8 then
|
|
||||||
return BrickColor.new "Deep orange"
|
|
||||||
elseif terrainValue == 9 then
|
|
||||||
return BrickColor.new "Dark orange"
|
|
||||||
elseif terrainValue == 10 then
|
|
||||||
return BrickColor.new "Reddish brown"
|
|
||||||
elseif terrainValue == 11 then
|
|
||||||
return BrickColor.new "Light orange"
|
|
||||||
elseif terrainValue == 12 then
|
|
||||||
return BrickColor.new "Light stone grey"
|
|
||||||
elseif terrainValue == 13 then
|
|
||||||
return BrickColor.new "Sand green"
|
|
||||||
elseif terrainValue == 14 then
|
|
||||||
return BrickColor.new "Medium stone grey"
|
|
||||||
elseif terrainValue == 15 then
|
|
||||||
return BrickColor.new "Really red"
|
|
||||||
elseif terrainValue == 16 then
|
|
||||||
return BrickColor.new "Really blue"
|
|
||||||
elseif terrainValue == 17 then
|
|
||||||
return BrickColor.new "Bright blue"
|
|
||||||
else
|
|
||||||
return BrickColor.new "Bright green"
|
|
||||||
end
|
end
|
||||||
|
return BrickColor.new "Bright green"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Used to create a highlighter that follows the mouse.
|
-- Used to create a highlighter that follows the mouse.
|
||||||
|
|
@ -155,32 +143,34 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Create the part that the highlighter will be attached to.
|
-- Create the part that the highlighter will be attached to.
|
||||||
highlighter.selectionPart = Instance.new "Part"
|
highlighter.selectionPart = New "Part" {
|
||||||
highlighter.selectionPart.Name = "SelectionPart"
|
Name = "SelectionPart",
|
||||||
highlighter.selectionPart.Archivable = false
|
Archivable = false,
|
||||||
highlighter.selectionPart.Transparency = 0.5
|
Transparency = 0.5,
|
||||||
highlighter.selectionPart.Anchored = true
|
Anchored = true,
|
||||||
highlighter.selectionPart.Locked = true
|
Locked = true,
|
||||||
highlighter.selectionPart.CanCollide = false
|
CanCollide = false,
|
||||||
highlighter.selectionPart.FormFactor = Enum.FormFactor.Custom
|
FormFactor = Enum.FormFactor.Custom,
|
||||||
highlighter.selectionPart.Size = Vector3.new(4, 4, 4)
|
Size = Vector3.new(4, 4, 4),
|
||||||
highlighter.selectionPart.BottomSurface = 0
|
BottomSurface = 0,
|
||||||
highlighter.selectionPart.TopSurface = 0
|
TopSurface = 0,
|
||||||
highlighter.selectionPart.BrickColor =
|
BrickColor = getClosestColorToTerrainMaterial(currentMaterial),
|
||||||
getClosestColorToTerrainMaterial(currentMaterial)
|
Parent = workspace,
|
||||||
highlighter.selectionPart.Parent = game.Workspace
|
}
|
||||||
|
|
||||||
local billboardGui = Instance.new "BillboardGui"
|
local billboardGui = New "BillboardGui" {
|
||||||
billboardGui.Size = UDim2.new(5, 0, 5, 0)
|
Size = UDim2.new(5, 0, 5, 0),
|
||||||
billboardGui.StudsOffset = Vector3.new(0, 2.5, 0)
|
StudsOffset = Vector3.new(0, 2.5, 0),
|
||||||
billboardGui.Parent = highlighter.selectionPart
|
Parent = highlighter.selectionPart,
|
||||||
|
}
|
||||||
|
|
||||||
local imageLabel = Instance.new "ImageLabel"
|
local imageLabel = New "ImageLabel" {
|
||||||
imageLabel.BackgroundTransparency = 1
|
BackgroundTransparency = 1,
|
||||||
imageLabel.Size = UDim2.new(1, 0, 1, 0)
|
Size = UDim2.new(1, 0, 1, 0),
|
||||||
imageLabel.Position = UDim2.new(-0.35, 0, -0.5, 0)
|
Position = UDim2.new(-0.35, 0, -0.5, 0),
|
||||||
imageLabel.Image = "http://banland.xyz/asset?id=82741829"
|
Image = "http://banland.xyz/asset?id=82741829",
|
||||||
imageLabel.Parent = billboardGui
|
Parent = billboardGui,
|
||||||
|
}
|
||||||
|
|
||||||
local lastTweenChange
|
local lastTweenChange
|
||||||
|
|
||||||
|
|
@ -197,7 +187,7 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
tweenDown = function()
|
tweenDown = function()
|
||||||
if
|
if
|
||||||
imageLabel
|
imageLabel
|
||||||
and imageLabel:IsDescendantOf(game.Workspace)
|
and imageLabel:IsDescendantOf(workspace)
|
||||||
and thisTweenStamp == lastTweenChange
|
and thisTweenStamp == lastTweenChange
|
||||||
then
|
then
|
||||||
imageLabel:TweenPosition(
|
imageLabel:TweenPosition(
|
||||||
|
|
@ -213,7 +203,7 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
tweenUp = function()
|
tweenUp = function()
|
||||||
if
|
if
|
||||||
imageLabel
|
imageLabel
|
||||||
and imageLabel:IsDescendantOf(game.Workspace)
|
and imageLabel:IsDescendantOf(workspace)
|
||||||
and thisTweenStamp == lastTweenChange
|
and thisTweenStamp == lastTweenChange
|
||||||
then
|
then
|
||||||
imageLabel:TweenPosition(
|
imageLabel:TweenPosition(
|
||||||
|
|
@ -249,8 +239,8 @@ function MouseHighlighter.Create(mouseUse)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if highlighter.selectionPart.Parent ~= game.Workspace then
|
if highlighter.selectionPart.Parent ~= workspace then
|
||||||
highlighter.selectionPart.Parent = game.Workspace
|
highlighter.selectionPart.Parent = workspace
|
||||||
startTween()
|
startTween()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -327,7 +317,7 @@ end
|
||||||
|
|
||||||
-- Show the highlighter.
|
-- Show the highlighter.
|
||||||
function MouseHighlighter:EnablePreview()
|
function MouseHighlighter:EnablePreview()
|
||||||
self.selectionPart.Parent = game.Workspace
|
self.selectionPart.Parent = workspace
|
||||||
startTween()
|
startTween()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -401,7 +391,7 @@ function ConfirmationPopup.Create(
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
FontSize = Enum.FontSize.Size14,
|
FontSize = Enum.FontSize.Size14,
|
||||||
TextWrap = true,
|
TextWrapped = true,
|
||||||
Font = Enum.Font.Arial,
|
Font = Enum.Font.Arial,
|
||||||
TextXAlignment = Enum.TextXAlignment.Center,
|
TextXAlignment = Enum.TextXAlignment.Center,
|
||||||
}
|
}
|
||||||
|
|
@ -596,7 +586,7 @@ local function ConfirmFloodFill(x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mouseDown(mouseD)
|
function mouseDown(mouseD)
|
||||||
if on and mouseD.Target == game.Workspace.Terrain then
|
if on and mouseD.Target == workspace.Terrain then
|
||||||
startCell = mouseHighlighter:GetPosition()
|
startCell = mouseHighlighter:GetPosition()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -824,7 +814,7 @@ Hydrate(helpFrame) {
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
TextYAlignment = Enum.TextYAlignment.Top,
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
TextWrap = true,
|
TextWrapped = true,
|
||||||
Text = [[
|
Text = [[
|
||||||
Quickly replace empty terrain cells with a selected material. Clicking the mouse will cause any empty terrain cells around the point clicked to be filled with the current material, and will also spread to surrounding empty cells (including any empty cells below, but not above).
|
Quickly replace empty terrain cells with a selected material. Clicking the mouse will cause any empty terrain cells around the point clicked to be filled with the current material, and will also spread to surrounding empty cells (including any empty cells below, but not above).
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue