Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property copying shortcut to material tool. #141

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions Tools/Material.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ local MaterialTool = {
}

MaterialTool.ManualText = [[<font face="GothamBlack" size="16">Material Tool 🛠</font>
Lets you change the material, transparency, and reflectance of parts.]]
Lets you change the material, transparency, and reflectance of parts.

<b>TIP:</b> Press <b><i>R</i></b> while hovering over a part to copy its material properties.]]


-- Container for temporary connections (disconnected automatically)
local Connections = {};
Expand All @@ -39,6 +42,7 @@ function MaterialTool:Equip()

-- Start up our interface
self:ShowUI()
BindShortcutKeys()

end;

Expand Down Expand Up @@ -85,6 +89,19 @@ local Materials = {
[Enum.Material.Wood] = 'Wood';
[Enum.Material.WoodPlanks] = 'Wood Planks';
[Enum.Material.Glass] = 'Glass';
[Enum.Material.Asphalt] = 'Asphalt';
[Enum.Material.Basalt] = 'Basalt';
[Enum.Material.CrackedLava] = 'Cracked Lava';
[Enum.Material.Glacier] = 'Glacier';
[Enum.Material.Ground] = 'Ground';
[Enum.Material.LeafyGrass] = 'Leafy Grass';
[Enum.Material.Limestone] = 'Limestone';
[Enum.Material.Mud] = 'Mud';
[Enum.Material.Pavement] = 'Pavement';
[Enum.Material.Rock] = 'Rock';
[Enum.Material.Salt] = 'Salt';
[Enum.Material.Sandstone] = 'Sandstone';
[Enum.Material.Snow] = 'Snow';
};

function MaterialTool:ShowUI()
Expand Down Expand Up @@ -180,6 +197,42 @@ function SyncInputToProperty(Property, Input)

end;

function BindShortcutKeys()
-- Enables useful shortcut keys for this tool

-- Track user input while this tool is equipped
table.insert(Connections, UserInputService.InputBegan:Connect(function (InputInfo, GameProcessedEvent)
-- Make sure this is an intentional event
if GameProcessedEvent then
return;
end;

-- Make sure this input is a key press
if InputInfo.UserInputType ~= Enum.UserInputType.Keyboard then
return;
end;

-- Make sure it wasn't pressed while typing
if UserInputService:GetFocusedTextBox() then
return;
end;

-- Check if the enter key was pressed
if InputInfo.KeyCode == Enum.KeyCode.R then

-- Set selection's properties to that of the target (if any)
if Core.Mouse.Target then
SetProperty('Material', Core.Mouse.Target.Material)
SetProperty('Transparency', Core.Mouse.Target.Transparency)
SetProperty('Reflectance', Core.Mouse.Target.Reflectance)
end;

end;

end));

end;

function SetProperty(Property, Value)

-- Make sure the given value is valid
Expand Down Expand Up @@ -379,4 +432,4 @@ function RegisterChange()
end;

-- Return the tool
return MaterialTool;
return MaterialTool;