Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Python ➜ Zmud <-> MC speedwalk converter.

Zmud <-> MC speedwalk converter.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Mon 18 Apr 2005 11:27 PM (UTC)

Amended on Tue 19 Apr 2005 12:45 AM (UTC) by Poromenos

Message
This poorly commented piece of code will convert a MC speedwalk string to Zmud stacked dirs and vice-versa:

def fnConvertDirs(strDirs, strFormat = 0):
    """0: Zmud to MUSHclient
       1: MUSHclient to Zmud"""

    lstNewDirs = []
    if strFormat == 0:
        # Strip list items.
        lstDirs = map(string.strip, strDirs.split(";"))
        strRepeat = ""

        # Repeat commands as many times as required.
        for strCommand in lstDirs:
            if strCommand[0] == "#":
                for strLetter in strCommand[1:]:
                    if strLetter.isdigit():
                        strRepeat += strLetter
                    else:
                        for intCounter in range(int(strRepeat)):
                            lstNewDirs.append(strCommand[strCommand.find(strLetter):].strip())
                        strRepeat = ""
                        break
            else:
                lstNewDirs.append(strCommand)

        # Enclose long commands in parentheses.
        lstNewDirs = map(lambda x: len(x) > 1 and "(" + x + ")" or x, lstNewDirs)

        intOccurrenceCounter = 1
        lstDirs = []
        # Append an empty element so the following algorithm works.
        lstNewDirs.append("")

        # Join adjacent same dirs in one ("n n" -> "2n").
        for intCounter in range(1, len(lstNewDirs)):
            if lstNewDirs[intCounter - 1] == lstNewDirs[intCounter]:
                intOccurrenceCounter += 1
            else:
                if intOccurrenceCounter > 1:
                    lstDirs.append(str(intOccurrenceCounter) + lstNewDirs[intCounter - 1])
                else:
                    lstDirs.append(lstNewDirs[intCounter - 1])
                intOccurrenceCounter = 1
        return(string.join(lstDirs))

    else:
        strTemp = ""
        strTimes = ""
        blnInCommand = False
        blnEvaluate = True
        for strLetter in strDirs:
            if strLetter == "(":
                blnInCommand = True
            elif strLetter == "/" and blnInCommand:
                blnEvaluate = False
            elif strLetter == ")" and blnInCommand:
                blnInCommand = False
                if strTimes != "":
                    lstNewDirs.append("#" + strTimes + " " + strTemp + ";")
                else:
                    lstNewDirs.append(strTemp  + ";")
                blnEvaluate = True
                strTimes = ""
                strTemp = ""
            elif strLetter.isdigit() and not blnInCommand:
                strTimes += strLetter
            elif strLetter.isspace() and not blnInCommand:
                pass
            elif blnInCommand:
                if blnEvaluate:
                    strTemp += strLetter
            else:
                if strTimes != "":
                    lstNewDirs.append("#" + strTimes + " " + strLetter + ";")
                else:
                    lstNewDirs.append(strLetter + ";")
                strTimes = ""
                strTemp = ""
        return(string.join(lstNewDirs)[:-1])

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nemix   (12 posts)  Bio
Date Reply #1 on Fri 30 Nov 2007 08:43 PM (UTC)
Message
I'm more of a vbscript person, would anyone be willing to take the time to convert this to a plugin?, perhaps to send the speedwalk on an alias.
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #2 on Mon 10 Dec 2007 09:25 PM (UTC)
Message
I was making a Lua plugin for this a while ago. I gave up when I was getting odd errors with parsing the zMUD sws into MUSHclient sws. Works great going from a stored alias to a zMUD alias though. I do not normally use the speedwalk function for MUSHclient though, since the mud I play supports a faster "run" command, where you can just spit out "run 3n5w2s" and it will just show room names while zipping along faster than a normal walk delay.

I'll see if I can scrounge up the script and fix it up again.

It is much easier to fight for one's ideals than to live up to them.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


16,677 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.