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

Inheritance diagram of direct.fsm.ClassicFSM

class ClassicFSM(name, states=[], initialStateName=None, finalStateName=None, onUndefTransition=2)[source]

Bases: direct.showbase.DirectObject.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

addState(self, state)[source]
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.

enterInitialState(self, argList=[])[source]
forceTransition(self, aStateName, enterArgList=[], exitArgList=[])[source]

force a transition – for debugging ONLY

getCurrentState(self)[source]
getFinalState(self)[source]
getInitialState(self)[source]
getName(self)[source]
getStateNamed(self, stateName)[source]

Return the state with given name if found, issue warning otherwise

getStates(self)[source]
hasStateNamed(self, stateName)[source]

Return True if stateName is a valid state, False otherwise.

isInternalStateInFlux(self)[source]
notify = <direct.directnotify.Notifier.Notifier object>
request(self, aStateName, enterArgList=[], exitArgList=[], force=0)[source]

Attempt transition from currentState to given one. Return true is transition exists to given state, false otherwise.

requestFinalState(self)[source]
setFinalState(self, finalStateName)[source]
setInitialState(self, initialStateName)[source]
setName(self, name)[source]
setStates(self, State[])[source]
view(self)[source]
printDebugFsmList()[source]