Updated contrib menusystem and talking_npc to make use of the dynamic command update properties. Also fixed a lingering error in talking npc that resolves #768.

This commit is contained in:
Griatch 2015-07-07 16:43:10 +02:00
parent ea0de32607
commit 095a1c0c13
2 changed files with 7 additions and 10 deletions

View file

@ -42,9 +42,6 @@ from evennia import syscmdkeys
from evennia import Command, CmdSet, utils
from evennia import default_cmds, logger
# imported only to make it available during execution of code blocks
import evennia
CMD_NOMATCH = syscmdkeys.CMD_NOMATCH
CMD_NOINPUT = syscmdkeys.CMD_NOINPUT
@ -398,7 +395,7 @@ class MenuNode(object):
else:
# this is the operable command, it moves us to the next node.
cmd = CmdMenuNode()
cmd.key = str(i + 1)
cmd.set_key(str(i + 1))
cmd.link = link
def _callback(self):
self.menutree.goto(self.link)
@ -406,7 +403,7 @@ class MenuNode(object):
# also custom commands get access to the menutree.
cmd.menutree = menutree
if self.keywords[i] and cmd.key not in (CMD_NOMATCH, CMD_NOINPUT):
cmd.aliases = [self.keywords[i]]
cmd.set_aliases(self.keywords[i])
self.cmdset.add(cmd)
def __str__(self):

View file

@ -8,7 +8,7 @@ This is a simple NPC object capable of holding a simple menu-driven
conversation. Create it by creating an object of typeclass
contrib.talking_npc.TalkingNPC, For example using @create:
@create John : contrib.talking_npc.TalkingNPC
@create/drop John : contrib.talking_npc.TalkingNPC
Walk up to it and give the talk command to strike up a conversation.
If there are many talkative npcs in the same room you will get to
@ -84,26 +84,26 @@ CONV = {"START": {"text": "Hello there, how can I help you?",
"linktexts": ["Hey, do you know what this 'Evennia' thing is all about?",
"What's your name, little NPC?"],
"keywords": None,
"code": None},
"callback": None},
"info1": {"text": "Oh, Evennia is where you are right now! Don't you feel the power?",
"links": ["info3", "info2", "END"],
"linktexts":["Sure, *I* do, not sure how you do though. You are just an NPC.",
"Sure I do. What's yer name, NPC?",
"Ok, bye for now then."],
"keywords": None,
"code": None},
"callback": None},
"info2": {"text": "My name is not really important ... I'm just an NPC after all.",
"links": ["info3", "info1"],
"linktexts": ["I didn't really want to know it anyhow.",
"Okay then, so what's this 'Evennia' thing about?"],
"keywords": None,
"code": None},
"callback": None},
"info3": {"text": "Well ... I'm sort of busy so, have to go. NPC business. Important stuff. You wouldn't understand.",
"links": ["END", "info2"],
"linktexts": ["Oookay ... I won't keep you. Bye.",
"Wait, why don't you tell me your name first?"],
"keywords": None,
"code": None},
"callback": None},
}