Finite State Machine - no request in module?

Im trying to learn about Finite State Machines (FSM) and have followed the manual closely, yet when I try to request my state from my FSM class, it always returns an error:

So I tried to use forcetransition, and error:

here is moveFSM:

from direct.fsm import FSM

class AvatarFSM(FSM.FSM):
    def __init__(self):#optional because FSM already defines __init__
        #if you do write your own, you *must* call the base __init__ :
        FSM.FSM.__init__(self,'avatarFSM')
        ##do your init code here
        
    def enterWalk(self):
        self.player.loop('walk')
        self.walksound.play()
        
        
    def exitWalk(self):
        self.player.stop()
        self.walksound.stop()

    def enterJump(self):
        self.player.loop('jump')
        self.walksound.play()
        
        
    def exitJump(self):
        self.player.stop()
        self.walksound.stop()
movefsm = AvatarFSM()

and here is the pertinent main.py info:

import movefsm
import direct.directbase.DirectStart 
from direct.actor.Actor import Actor
from direct.fsm import FSM

def move(self, task):
     if (self.keyMap["jump"]!=0):
                movefsm.request('Jump')

Any suggestions on why it wont use the FSM commands?

Well, you’re probably calling the FSM module instead of the FSM class somewhere. There’s a difference between this:

from direct.fsm import FSM 

and this:

from direct.fsm.FSM import FSM 

Thank you for your quick reply :wink:

However that change returned to me this:

import movefsm
  File "movefsm.py", line 3, in <module>
    class AvatarFSM(FSM.FSM):
AttributeError: class FSM has no attribute 'FSM'

I am trying to follow the manual close, is there something else I am missing?

movefsm.request(‘Jump’)

=>

movefsm.movefsm.request(‘Jump’)

Also, better use a different name for the module and global variables. It is quite confusing sometimes.

Sorry for not posting back, been very busy - But thank you very much chleung and pro soft the info you provided was key.