creating features
tutorial for building custom lcs features.
feature basics
a feature is a lua module that exports two functions:
return {
enable = function()
-- your feature code
end,
disable = function()
-- cleanup code
end
}
simple feature example
let's create a feature that changes fog:
-- features/customFog.lua
local Lighting = game:GetService("Lighting")
local originalFogEnd
local originalFogColor
return {
enable = function()
-- save original values
originalFogEnd = Lighting.FogEnd
originalFogColor = Lighting.FogColor
-- apply custom fog
Lighting.FogEnd = 100
Lighting.FogColor = Color3.fromRGB(255, 0, 0)
end,
disable = function()
-- restore original values
Lighting.FogEnd = originalFogEnd
Lighting.FogColor = originalFogColor
end
}
add to config.lua:
{
id = "customFog",
name = "custom fog",
description = "adds red fog for dramatic effect",
path = "features/customFog.lua",
enabled = true
}
feature with events
features often need event connections:
-- features/autoHideNewPlayers.lua
local Players = game:GetService("Players")
local connections = {}
local function hidePlayer(player)
if player.Character then
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") then
part.LocalTransparencyModifier = 1
end
end
end
end
return {
enable = function()
-- hide existing players
for _, player in ipairs(Players:GetPlayers()) do
hidePlayer(player)
end
-- watch for new players
connections.playerAdded = Players.PlayerAdded:Connect(hidePlayer)
end,
disable = function()
-- restore players
for _, player in ipairs(Players:GetPlayers()) do
if player.Character then
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") then
part.LocalTransparencyModifier = 0
end
end
end
end
-- disconnect events
for _, connection in pairs(connections) do
connection:Disconnect()
end
connections = {}
end
}
best practices
always clean up
disable = function()
-- disconnect all connections
-- restore original values
-- clear tables
-- remove created instances
end
handle edge cases
enable = function()
-- check if objects exist
if not workspace:FindFirstChild("Camera") then
warn("camera not found!")
return
end
-- proceed with feature
end
use pcall for safety
enable = function()
local success, error = pcall(function()
-- feature code
end)
if not success then
warn("feature failed:", error)
end
end
store state properly
local featureState = {
originalValue = nil,
connections = {},
instances = {}
}
return {
enable = function()
featureState.originalValue = something
-- use featureState
end,
disable = function()
-- restore from featureState
featureState = {originalValue = nil, connections = {}, instances = {}}
end
}
advanced features
with configuration
local CONFIG = {
SPEED = 2,
COLOR = Color3.fromRGB(255, 0, 0)
}
return {
enable = function()
-- use CONFIG values
end,
disable = function()
-- cleanup
end
}
with dependencies
local HttpService = game:GetService("HttpService")
local TweenService = game:GetService("TweenService")
return {
enable = function()
-- use services
end,
disable = function()
-- cleanup
end
}
with helpers
local function helperFunction(param)
-- helper code
end
local function anotherHelper()
-- more helpers
end
return {
enable = function()
helperFunction("test")
anotherHelper()
end,
disable = function()
-- cleanup
end
}
testing features
local testing
- create feature file
- add to config.lua
- load lcs
- press z to test enable
- press z to test disable
- check for errors
edge case testing
- test with no players
- test with many players
- test rapid enable/disable
- test in different games
- check memory leaks
publishing features
to your fork
- add feature file
- update config.lua
- commit and push
- others load from your fork
contributing to main repo
- fork main repository
- create feature branch
- add feature + docs
- submit pull request
- wait for review
feature ideas
some ideas for custom features:
- time of day control
- weather effects
- custom lighting
- sound management
- character modifications
- world manipulation
- ui enhancements
- recording helpers