Transition
A move from one State to another, fired by a trigger. Insert it into the Transitions list of the state it leaves.
table.insert(locked.Transitions, Felix.Transition.new({
From = "Locked",
Target = "Open",
Triggers = { "Unlock" },
Conditions = { function(machine) return machine.Context.HasKey end },
Effects = { function(machine) playSound("Click") end },
}))
Properties
From
Transition.From: string
The state this transition leaves. It must match the state whose Transitions list it's in (Machine:Start
checks), or be "*" for transitions in Machine.AnyTransitions.
Target
Transition.Target: stringThe name of the state to enter.
Triggers
Transition.Triggers: {string}The trigger names that fire this transition.
Conditions
Guards. All must return true for the transition to fire.
Effects
Actions, run in order after the old state exits and before the new state enters.
Priority
Transition.Priority: number?
How hard this transition interrupts. It only fires if Priority is at least the current state's
State.Resistance. Defaults to 0. Use math.huge for transitions nothing should block, like dying.
Except
Transition.Except: {string}?For transitions in [Machine.AnyTransitions]: states it doesn't fire from. A state's children are excluded too.
Functions
new
Transition.new(params: {From: string,Target: string,Triggers: {string},Priority: number?,Except: {string}?}) → Transition