-def help(topic=None):
+def help(topic=None, direct=0):
+ ## Added direct flag: if we are in direct mode, we need to handle
+ ## formatting here; otherwise, we'll take care of formatting in softcode
+ ## (JP)
global helpDB
if not topic:
- output = "Available help topics:\n\n"
+ if direct:
+ output = "Available help topics:\n\n"
+ else:
+ output=[]
lst = filter(lambda x:helpDB[x].initial, helpDB.keys())
lst.sort()
for topic in lst:
- output = output + " "+ topic + "\n"
- return output + "\n"
+ if direct:
+ output = output + " "+ topic + "\n"
+ else:
+ output.append(topic)
+ return output
else:
try:
return helpDB[topic].show()
@@ -112,16 +121,30 @@
return "Ambiguous topic:\n " + string.join(lst,'\n ')+'\n'
return helpDB[lst[0]].show()
-def addTopic(topic):
+def addTopic(topic, syntax='', desc='', initial=0, direct=0):
+ ## In order to add topics from within MOOP, we need addTopic to be able
+ ## to handle a complete entry (JP)
global helpDB
- hr = HelpRec()
- hr.enter()
- helpDB[topic] = hr
+ if direct:
+ ## In direct mode, we can add interactively (JP)
+ hr = HelpRec()
+ hr.enter()
+ helpDB[topic] = hr
+ else:
+ ## In game mode, we currently have to pass the whole entry at once (JP)
+ helpDB[topic] = HelpRec(syntax, desc, initial)
-def deleteTopic(topic):
+def deleteTopic(topic, direct=0):
+ ## Added return values so softcode can handle formatting success/failure
+ ## messages (JP)
global helpDB
- try: del helpDB[topic]
- except: print "Couldn't delete topic",topic
+ try:
+ del helpDB[topic]
+ return True
+ except:
+ if direct:
+ print "Couldn't delete topic %s." % topic
+ return False