TickService - Styxling/Feather GitHub Wiki
The TickService module standardizes the creation and usage of TickObjects; visual slider elements that represent a boolean (true/false) state. This module is responsible for handling the visuals and smooth slide effects of these TickObjects.
TickObjects are typically used in UIs to allow users to toggle options, and they support locking, custom data overrides, and smooth tweening animations.
Default Data Values
The module defines a table called defaultData which includes:
- Color Settings:
Ball_Color(default: white)Background_True(default: green)Background_False(default: grey)Background_Locked(default: dark grey)Ball_Color_Locked(default: medium grey)
- Position Settings:
True_Position: AnchorPoint and Position for the tick when set to true.False_Position: AnchorPoint and Position for the tick when set to false.
- Tween Settings:
Tween_Info: TweenInfo object defining the tween duration (default: 0.3 seconds)
These defaults can be globally modified using TickService.SetMasterData().
API
Global Configuration
TickService.SetMasterData(defaultDataTable)
Updates the global default settings for all TickObjects. Only updates keys that already exist indefaultData.
TickObject Creation
local tick = TickService.New(instance)
Creates a new TickObject for a given GUI instance.instanceshould have a structure where the TickObject’s elements can be found (e.g.,TickboxandTickbox.Ball).
TickObject Methods
-
tick:SetData(customDataTable)
Overrides the default settings for this TickObject with a custom data table. -
tick:Update(boolean)
Smoothly updates the TickObject to reflect the given boolean state (true/false) using tweening. -
tick:InstantUpdate(boolean)
Instantly updates the TickObject state without tweening. -
tick:Lock(boolean)
Locks or unlocks the TickObject. When locked, an alternate color scheme is applied.
Usage Example
local Directory = require(ServerStorage.Directory.MainModule)
local TickService = Directory("_replicated", "TickService")
-- Set global defaults if needed:
TickService.SetMasterData({
Ball_Color = Color3.new(1, 1, 1),
Background_True = Color3.fromRGB(0, 200, 0),
Background_False = Color3.fromRGB(100, 100, 100),
-- Other defaults can be overridden here.
})
-- Create a new TickObject from a GUI element
local tickObject = TickService.New(someGuiElement)
-- Optionally override individual settings
tickObject:SetData({
Tween_Info = TweenInfo.new(0.5), -- Change tween duration to 0.5 seconds
})
-- Update TickObject with a smooth slide effect
tickObject:Update(true)
-- Instantly update TickObject (no tween)
tickObject:InstantUpdate(false)
-- Lock the TickObject (applies locked color scheme)
tickObject:Lock(true)