Mercurial > skaapsteker
changeset 233:8ea658969f47
Fix on_entry and on_exit handling.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Thu, 07 Apr 2011 11:05:31 +0200 |
parents | 479fb1e4d130 |
children | a661b6621ec4 |
files | skaapsteker/dialogue.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/dialogue.py Thu Apr 07 01:53:27 2011 +0200 +++ b/skaapsteker/dialogue.py Thu Apr 07 11:05:31 2011 +0200 @@ -98,12 +98,16 @@ self.on_entry = compile(on_entry, "<%s>" % ":".join(base_path + ["on_entry"]), "exec") + else: + self.on_entry = None on_exit = state_src.get("on_exit", None) if on_exit is not None: self.on_exit = compile(on_exit, "<%s>" % ":".join(base_path + ["on_exit"]), "exec") + else: + self.on_exit = None def __repr__(self): return "<%r name=%r>" % (self.__class__.__name__, self.name) @@ -115,10 +119,12 @@ return next_state def enter(self, my_locals): - self.on_entry(my_locals, {}, my_locals.copy()) + if self.on_entry is not None: + exec(self.on_entry, {}, my_locals.copy()) def leave(self, my_locals): - self.on_exit(my_locals, {}, my_locals.copy()) + if self.on_exit is not None: + exec(self.on_exit, {}, my_locals.copy()) class Trigger(object):