def continue_dialogue(self, npc, dialogue, sentence): """ Continue current dialogue. Args: npc: (optional) NPC's object. dialogue: current dialogue's key. sentence: current sentence's ordinal. Returns: None """ if GAME_SETTINGS.get("auto_resume_dialogues"): # Check current dialogue. if not self.db.current_dialogue: return if (dialogue, sentence) not in self.db.current_dialogue["sentences_all"]: # Can not find specified dialogue in current dialogues. return try: # Finish current sentence DIALOGUE_HANDLER.finish_sentence(self, npc, dialogue, sentence) except Exception, e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_tracemsg(ostring)
class CmdDialogue(Command): """ Talk to NPC, using dialogues stored in db. Usage: {"cmd":"dialogue", "args":{"npc":<npc's dbref>, "dialogue":[<talk's dialogue>], "sentence":[<talk's sentence>]} } Dialogue and sentence refer to the current sentence. If dialogue or sentence is null, use the npc's default dialogue. """ key = "dialogue" locks = "cmd:all()" help_cateogory = "General" def func(self): "Talk to NPC." caller = self.caller if not self.args: caller.msg({"alert":LS("You should talk to someone.")}) return if not "npc" in self.args: caller.msg({"alert":LS("You should talk to someone.")}) return # Get the npc at the player's location. npc = caller.search(self.args["npc"], location=caller.location) if not npc: caller.msg({"alert":LS("Can not find the one to talk.")}) return # Get the current sentence. dialogue = "" sentence = 0 have_current_dlg = False try: dialogue = self.args["dialogue"] sentence = int(self.args["sentence"]) have_current_dlg = True except Exception, e: pass if have_current_dlg: try: # Finish this sentence DIALOGUE_HANDLER.finish_sentence(caller, dialogue, sentence) except Exception, e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_errmsg(ostring) logger.log_errmsg(traceback.format_exc())
def continue_dialogue(self, npc, dialogue, sentence): """ Continue current dialogue. Args: npc: (optional) NPC's object. dialogue: current dialogue's key. sentence: current sentence's ordinal. Returns: None """ if GAME_SETTINGS.get("auto_resume_dialogues"): # Check current dialogue. if not self.db.current_dialogue: return if (dialogue, sentence) not in self.db.current_dialogue["sentences_all"]: # Can not find specified dialogue in current dialogues. return try: # Finish current sentence DIALOGUE_HANDLER.finish_sentence(self, npc, dialogue, sentence) except Exception as e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_tracemsg(ostring) # Get next sentences. sentences = DIALOGUE_HANDLER.get_next_sentences( self, npc, dialogue, sentence) # Send dialogues_list to the player. self.save_current_dialogue(sentences, npc) self.msg({"dialogue": sentences}) if not sentences: # dialogue finished, refresh surroundings self.show_location()