direct.fsm.ClassicFSM
from direct.fsm.ClassicFSM import ClassicFSM, printDebugFsmList
Finite State Machine module: contains the ClassicFSM class.
Note
This module and class exist only for backward compatibility with
existing code. New code should use the FSM
module instead.
Inheritance diagram
- class ClassicFSM(name, states=[], initialStateName=None, finalStateName=None, onUndefTransition=2)[source]
Bases:
DirectObject
Finite State Machine class.
This module and class exist only for backward compatibility with existing code. New code should use the FSM class instead.
- ALLOW = 0
- DISALLOW = 1
- DISALLOW_VERBOSE = 2
- ERROR = 3
- __init__(self, string, State[], string, string, int)[source]
ClassicFSM constructor: takes name, list of states, initial state and final state as:
fsm = ClassicFSM.ClassicFSM('stopLight', [State.State('red', enterRed, exitRed, ['green']), State.State('yellow', enterYellow, exitYellow, ['red']), State.State('green', enterGreen, exitGreen, ['yellow'])], 'red', 'red')
each state’s last argument, a list of allowed state transitions, is optional; if left out (or explicitly specified to be State.State.Any) then any transition from the state is ‘defined’ and allowed
‘onUndefTransition’ flag determines behavior when undefined transition is requested; see flag definitions above
- conditional_request(self, aStateName, enterArgList=[], exitArgList=[])[source]
‘if this transition is defined, do it’ Attempt transition from currentState to given one, if it exists. Return true if transition exists to given state, false otherwise. It is NOT an error/warning to attempt a cond_request if the transition doesn’t exist. This lets people be sloppy about ClassicFSM transitions, letting the same fn be used for different states that may not have the same out transitions.
- forceTransition(self, aStateName, enterArgList=[], exitArgList=[])[source]
force a transition – for debugging ONLY
- getStateNamed(self, stateName)[source]
Return the state with given name if found, issue warning otherwise
- notify = <direct.directnotify.Notifier.Notifier object>