Browse Source

adding getCurrentStateOrTransition()

Josh Wilson 16 years ago
parent
commit
f4e55629fa
1 changed files with 12 additions and 0 deletions
  1. 12 0
      direct/src/fsm/FSM.py

+ 12 - 0
direct/src/fsm/FSM.py

@@ -204,6 +204,18 @@ class FSM(DirectObject):
         finally:
         finally:
             self.fsmLock.release()
             self.fsmLock.release()
 
 
+    def getCurrentStateOrTransition(self):
+        # Returns the current state if we are in a state now, or the
+        # transition we are performing if we are currently within
+        # the enter or exit function for a state.
+        self.fsmLock.acquire()
+        try:
+            if self.state:
+                return self.state
+            return '%s -> %s' % (self.oldState, self.newState)
+        finally:
+            self.fsmLock.release()
+
     def isInTransition(self):
     def isInTransition(self):
         self.fsmLock.acquire()
         self.fsmLock.acquire()
         try:
         try: