# HG changeset patch # User Simon Cross # Date 1302289092 -7200 # Node ID 0dbb50d0776411de8302de500bc1cc1927b90093 # Parent 71f15f6e92749ef2094a0ea6a5598d1600989e79 Poke the current state before checking to see if there is text in case the world has changed and it is time for the state machine to move on. diff -r 71f15f6e9274 -r 0dbb50d07764 skaapsteker/dialogue.py --- a/skaapsteker/dialogue.py Fri Apr 08 20:52:47 2011 +0200 +++ b/skaapsteker/dialogue.py Fri Apr 08 20:58:12 2011 +0200 @@ -29,6 +29,7 @@ return self.states[self.state] def has_text(self): + self.poke() return bool(self.states[self.state].text) def event(self, ev): @@ -52,6 +53,11 @@ def auto_next(self): self.event(DsmEvent(auto_next=True)) + def poke(self): + # poke the current state to see if it feels like making + # a transition. + self.event(DsmEvent(poke=True)) + class AttrDict(dict): @@ -63,10 +69,11 @@ class DsmEvent(object): - def __init__(self, choice=None, auto_next=False): + def __init__(self, choice=None, auto_next=False, poke=False): self.items = { "choice": choice, "auto_next": auto_next, + "poke": poke, }