def run(self,tick): Updatable.run(self,tick) try: while len(self.commandQueue) > 0: command = interpret(self.commandQueue.pop(0),self) if step(command): self.scriptsQueue.append(command) if not self.commandScript and len(self.scriptsQueue): self.commandScript = self.scriptsQueue.pop(0) if self.commandScript: if not step(self.commandScript): self.commandScript = None except BreakException: pass except GameException, e: self.sendMessage("exception",error=str(e)) self.runTrigger("failure")
def do(self,script=None): """\ Execute a common task. Run one of your stored scripts. do <name> Example: do gohome """ if not script: self.sendMessage("scriptNames",scripts=self.scripts) return if script in self.scripts: self.scriptsQueue.append(interpret(self.scripts[script],self)) else: raise GameException("Cannot find script %s" % script)