Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ATTRIBUTE LOADER --
- -- BY: PERSONIFIEDPIZZA --
- local PROPERTIES_LIST = {
- Lighting = {"Ambient", "Archivable", "Brightness", "ClockTime", "ColorShift_Bottom", "ColorShift_Top", "ExposureCompensation", "FogColor", "FogEnd", "FogStart", "GeographicLatitude", "GlobalShadows", "Name", "OutdoorAmbient", "Outlines", "Parent", "TimeOfDay"};
- }
- local STOREABLE_PROPERTIES = {
- "string";
- "boolean";
- "number";
- "UDim";
- "UDim2",
- "BrickColor";
- "Color3";
- "Vector2";
- "Vector3";
- "NumberSequence";
- "ColorSequence";
- "NumberRange";
- "Rect";
- }
- local function store(instance)
- local newConfig = Instance.new("Configuration")
- local className = instance.ClassName
- newConfig.Name = className.."Configurations"
- newConfig:SetAttribute("ClassName", className)
- for _, propertyName in ipairs(PROPERTIES_LIST[className]) do
- local propertyValue = instance[propertyName]
- local propertyType = typeof(propertyValue)
- if table.find(STOREABLE_PROPERTIES, propertyType) then
- newConfig:SetAttribute(propertyName, propertyValue)
- elseif propertyType == "EnumItem" then
- newConfig:SetAttribute(propertyName, propertyValue.Value)
- end
- end
- return newConfig
- end
- local function apply(instance, config)
- local attributes = config:GetAttributes()
- local attributeClassName = attributes["ClassName"]
- if attributeClassName ~= instance.ClassName then
- warn("Can't apply configuration to the wrong class! ["..instance.ClassName..","..attributeClassName.."]")
- return
- end
- attributes["ClassName"] = nil
- for attributeName, attributeValue in pairs(attributes) do
- instance[attributeName] = attributeValue
- end
- end
- -- LIGHTING CONFIGURATIONS LOADER --
- -- BY: PERSONIFIEDPIZZA --
- local Lighting = game:GetService("Lighting")
- local Selection = game:GetService("Selection")
- local ChangeHistoryService = game:GetService("ChangeHistoryService")
- local function storeLightingConfiguration()
- ChangeHistoryService:SetWaypoint("Storing LightingConfiguration")
- local config = store(Lighting)
- local folder = Lighting:FindFirstChild("LightingConfigurations")
- if not folder then
- folder = Instance.new("Folder")
- folder.Name = "LightingConfigurations"
- folder.Parent = Lighting
- end
- config.Parent = folder
- Selection:Set({config})
- ChangeHistoryService:SetWaypoint("Stored LightingConfiguration")
- end
- local function isLightingConfiguration(instance)
- local classNameAttribute = instance:GetAttribute("ClassName")
- if classNameAttribute and (classNameAttribute == "Lighting") and (instance:IsA("Configuration")) then
- return true
- end
- end
- local function tryLightingConfiguration()
- local selected = Selection:Get()
- local config
- for _, instance in ipairs(selected) do
- if isLightingConfiguration(instance) then
- config = instance
- Selection:Set({instance})
- break
- end
- end
- if config then
- ChangeHistoryService:SetWaypoint("Applying LightingConfiguration")
- apply(Lighting, config)
- ChangeHistoryService:SetWaypoint("Applied LightingConfiguration")
- return true
- end
- end
- local function applyLightingConfiguration()
- local success = tryLightingConfiguration()
- if success then
- return true
- end
- print("Select a LightingConfiguration!")
- Selection.SelectionChanged:Wait()
- local success = tryLightingConfiguration()
- if success then
- return true
- end
- print("No LightingConfiguration selected!")
- end
- -- LIGHTING CONFIGURATIONS PLUGIN --
- -- BY: PERSONIFIEDPIZZA --
- local toolbar = plugin:CreateToolbar("Lighting Configurations")
- local storeButton = toolbar:CreateButton("Store Configuration", "Stores current Configuration in Lighting", "http://www.roblox.com/asset/?id=7167747940")
- local applyButton = toolbar:CreateButton("Apply Configuration", "Applys selected Configuration to Lighting", "http://www.roblox.com/asset/?id=7167748754")
- storeButton.ClickableWhenViewportHidden = true
- applyButton.ClickableWhenViewportHidden = true
- local storeButtonClickId = 0
- storeButton.Click:Connect(function()
- storeButtonClickId += 1
- local myClickId = storeButtonClickId
- storeLightingConfiguration()
- wait(0.1)
- if myClickId == storeButtonClickId then
- storeButton:SetActive(false)
- end
- end)
- local applyButtonClickId = 0
- applyButton.Click:Connect(function()
- applyButtonClickId += 1
- local myClickId = applyButtonClickId
- applyLightingConfiguration()
- wait(0.1)
- if myClickId == applyButtonClickId then
- storeButton:SetActive(false)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement