What is Combo?
Combo is a lightweight library designed to provide an easy way to add input sequences to your Roblox game. On initialization, it automatically starts listening for the actions defined in its configuration, and allows you to easily define sequences using said actions.
What does this do?
Simply put, it allows you to easily define and manage input sequences. You can also use it as just a general input manager.
Combo records the actions defined in its configuration, as well as the time between inputs. When it detects you’ve inputted a previously-defined sequence, it fires that sequence’s signal, which can be grabbed through the GetSignal() function.
Github: GitHub - stardustdtm/combo: Combo is a lightweight library designed to provide an easy way to add input sequences to your Roblox game. · GitHub
Toolbox: https://create.roblox.com/store/asset/140420784512201
API Reference
Types
type SequenceFrame = {
Input: string,
Modifiers: {string}?,
MinDelay: number?,
MaxDelay: number?,
Condition: (() -> boolean)?
}
type Sequence = {
Name: string,
Sequence: {SequenceFrame},
Priority: number,
ClearBuffer: boolean?,
}
type SequenceSignal = {
Name: string,
Signal: Signal.Signal
}
type BufferedInput = {
Input : string,
Modifiers : {string},
Time : number,
}
type Combo = {
_Buffer: {BufferedInput},
_Held: {string},
_Sequences: {Sequence},
_Signals: {SequenceSignal},
_Context: InputContext,
_Player: Player,
_Enabled: boolean,
_DisabledTimer: number,
AddSequence: (self: Combo, Sequence: Sequence) -> (),
Disable: (self: Combo, Time: number?) -> (),
Enable: (self: Combo) -> (),
Destroy: (self: Combo) -> (),
GetSignal: (self: Combo, Name: string) -> Signal.Signal,
ClearSequences: (self: Combo) -> (),
ClearBuffer: (self: Combo) -> (),
RemoveSequence: (self: Combo, Sequence: string) -> (),
GetEnabled: (self: Combo) -> boolean,
GetSequences: (self: Combo) -> {Sequence},
GetBuffer: (self: Combo) -> {BufferedInput},
GetHeld: (self: Combo) -> {string},
_RegisterAction: (self: Combo, Action: string) -> (),
_CleanBuffer: (self: Combo) -> (),
_FindSequences: (self: Combo) -> (),
_CheckModifiers: (self: Combo, Required: {string}?) -> (),
_CheckForSequence: (self: Combo, Sequence: Sequence) -> (),
_HeartbeatConnection: RBXScriptConnection,
}
Methods
Combo.new(): Combo
-- Creates and starts a new Combo instance
Combo:AddSequence(Sequence: Sequence)
-- Registers an input sequence to the detection system
Combo:Disable(Time: Number?)
-- Disables sequence detection. If a number is specified, starts a timer for when sequence detection is reenabled
Combo:GetSignal(Name: string): Signal?
-- Returns a signal tied to the input sequence of the given name. If no signal is found, returns nil
Combo:ClearSequences()
-- Clears the current Combo instance's sequence registry
Combo:ClearBuffer()
-- Clears the current Combo instance's input memory
Combo:RemoveSequence(Sequence: string)
-- Removes a sequence from the Combo instance's registry
Combo:Destroy()
-- Deletes the current Combo instance
Combo:GetEnabled(): boolean
-- Returns whether the current Combo instance is enabled
Combo:GetSequences(): {Sequence}
-- Returns the full list of registered sequences
Combo:GetBuffer(): {BufferedInput}
-- Returns the full list of stored actions
Combo:GetHeld(): {string}
-- Returns the full list of currently held actions
Usage example
local ComboModule = require(path.to.Combo)
local Combo = ComboModule.new()
Combo:AddSequence({
Name = "Melee",
Sequence = {
{Input = "M1"}
},
Priority = 1,
ClearBuffer = false
})
Combo:AddSequence({
Name = "Combo B",
Sequence = {
{Input = "M1",},
{Input = "M1",},
{Input = "M1", MinDelay = 0.4, MaxDelay = 0.75}
},
Priority = 2,
ClearBuffer = true
})
Combo:AddSequence({
Name = "Stinger",
Sequence = {
{
Input = "M1",
Condition = function()
-- Moving direction check
-- If forward then return true
end
}
},
Priority = 3,
ClearBuffer = true
})
Combo:GetSignal("Melee"):Connect(function()
-- Melee logic
end)
Combo:GetSignal("Combo B"):Connect(function()
-- Delayed combo ender
end)
Combo:GetSignal("Stinger"):Connect(function()
-- Dash attack
end)