-
-
Save Gabys2005/8db2bd70698339cbb8a75aee6ffb79c6 to your computer and use it in GitHub Desktop.
GLights 5 StacyPilot addon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local core = require(script.Parent.Parent.Core) | |
local glightsMain = require(workspace.GLights.Scripts.Core.Main) | |
local lightCores = glightsMain.GetAll() | |
local function registerRecordingEvents(glightsCore) | |
local id = glightsCore.Settings.Core.UniqueName | |
local lightChanger = glightsCore.LightChanger | |
local events = lightChanger.Events | |
local function record(eventName, additionalParam) | |
return function(...) | |
if additionalParam ~= nil then | |
core:Record(`GLights-{id}`, eventName, ..., additionalParam) | |
else | |
core:Record(`GLights-{id}`, eventName, ...) | |
end | |
end | |
end | |
events.SmoothColorChanged:Connect(record("SetSmoothColor")) | |
events.CueSpeedChanged:Connect(record("SetCueSpeed")) | |
events.CueEnabled:Connect(record("Cue", true)) | |
events.CueDisabled:Connect(record("Cue", false)) | |
events.LightsOn:Connect(record("On")) | |
events.LightsOff:Connect(record("Off")) | |
events.LightsFadeOn:Connect(record("FadeOn")) | |
events.LightsFadeOff:Connect(record("FadeOff")) | |
if table.find(lightChanger.Tags, "HasGobo") then | |
events.GoboOn:Connect(record("GoboOn")) | |
events.GoboOff:Connect(record("GoboOff")) | |
events.GoboFadeOn:Connect(record("GoboFadeOn")) | |
events.GoboFadeOff:Connect(record("GoboFadeOff")) | |
end | |
events.ColorChanged:Connect(record("Color")) | |
events.LightsReset:Connect(record("Reset")) | |
events.LightsHardReset:Connect(record("HardReset")) | |
if table.find(lightChanger.Tags, "HasBeams") then | |
events.BeamThicknessChanged:Connect(record("BeamThickness")) | |
events.BeamBrightnessChanged:Connect(record("BeamBrightness")) | |
end | |
if table.find(lightChanger.Tags, "HasTilt") then | |
events.TiltChanged:Connect(record("Tilt")) | |
end | |
if table.find(lightChanger.Tags, "HasPan") then | |
events.PanChanged:Connect(record("Pan")) | |
end | |
if table.find(lightChanger.Tags, "HasMotors") then | |
events.MotorSpeedChanged:Connect(record("MotorSpeed")) | |
end | |
core:RegisterResponse(`GLights-{id}`, function(data) | |
local func = data[1] | |
local params = {} | |
for i = 2, #data do | |
table.insert(params, data[i]) | |
end | |
glightsCore.LightChanger[func](glightsCore.LightChanger, table.unpack(params)) | |
end) | |
end | |
for _, module in lightCores do | |
registerRecordingEvents(module) | |
end | |
glightsMain.Events.NewLightsLoaded:Connect(function(module) | |
registerRecordingEvents(module) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment