--- moop-2.2/lib/moop.py        Sat Mar 27 21:26:42 2004
+++ moop/lib/moop.py    Mon Oct  4 09:33:18 2004
@@ -2149,6 +2163,11 @@
        'Directory':Directory,
        'Func':Func,
        'help':moophelp.help,
+        'helpadd':moophelp.addTopic,
+        'helpdel':moophelp.deleteTopic,
+        'helplist':moophelp.helpDB.keys,
+        'hLoad':moophelp.hLoad,
+        'hSave':moophelp.hSave,
        'globalkeys':globalkeys,
        'marksub':marksub,
        'md5':md5,
--- moop-2.2/lib/moophelp.py    Sat Mar 27 21:26:42 2004
+++ moop/lib/moophelp.py        Sun Oct 10 02:01:42 2004
@@ -14,17 +14,17 @@
    def __init__(self, syntax='', desc='', initial=0):
        self.syntax = syntax        # one-line syntax summary
        self.desc = desc            # long description
-        self.initial = initial        # if 1, appears in initial "topics" list
+        self.initial = initial      # if 1, appears in initial "topics" list

    def __repr__(self):
        return "HelpRec(syntax=%s, desc=%s, initial=%s)" % (`self.syntax`,
-                                                           `self.desc`,
-                                                           self.initial)
+                                                            `self.desc`,
+                                                            self.initial)
    def show(self):
        if self.syntax:
-            return "Syntax: " + self.syntax + "\n" + self.desc + "\n\n"
+            return "Syntax: " + self.syntax + "\n" + self.desc + "\n"
        else:
-            return self.desc + "\n\n"
+            return self.desc + "\n"

    def enter(self):
        self.syntax = raw_input("Enter syntax string: ")
@@ -89,15 +89,24 @@
    return "Creating empty help database..."
    helpDB = {}

-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

def popDB():
    done = 0
@@ -155,13 +178,13 @@
            else:
                hImport()
        elif cmd == ".h" or cmd == ".d":
-            if cmd == ".h": print help(arg)
-            elif cmd==".d": deleteTopic(arg)
+            if cmd == ".h": print help(arg, direct=1)
+            elif cmd==".d": deleteTopic(arg, direct=1)
        elif cmd == ".?":
            print helpStr
        elif cmd == ".": pass
        elif cmd == "": pass
-        else: addTopic(foo)
+        else: addTopic(foo, direct=1)

if __name__ == '__main__':
    popDB()