Balances

by Unknown

Back to Mechanic's Corner.

Unknown2005-01-30 12:41:04
QUOTE(ElessarNightshade @ Jan 22 2005, 06:55 PM)
How do I do this for MUSHclient?
33705



If you have Python then you can use PyAchaea (pyachaea0.tripod.com) for this. Though it still doesn't have a Lusternia prompt, but you can make your own. Here's the one I use:

CODE

from PyAchaea.prompts import PromptObject
LusterniaPrompt = PromptObject("(?P+)h, " +\\
                                               "(?P+)m, " +\\
                                               "(?P+)e, " +\\
                                               "(?P+)p " +\\
                                               "(?P((?:e|)(?:x|)(?:k|)(?:d|)(?:b|)(?:p|))")
from PyAchaea.Avatar import Avatar
my_avatar = Avatar(world)
my_avatar.setPrompt(LusterniaPrompt)



Then you just set up the OnPluginPartialLine function using that prompt:

CODE

OnPluginPartialLine = my_avatar.providePartialLine()


And you can get any of the prompt info by calling methods of my_avatar. For example to figure out whether you have balance you'd do:

CODE

if "x" in my_avatar.getStatus():
    world.Note ("I have balance!")
else:
    world.Note ("I don't have balance.")


The plus to this is though it requires some setting up, after you have it in some plugin, you don't need to save the status line in any variables - you can get it from anywhere as long as that anywhere is running Python. The first two code snippets above need to be contained in some plugin, and the third one can be run from any script, you just need to put:

CODE

from PyAchaea.Avatar import Avatar
my_avatar = Avatar(world)


lines in the beginning of that script and you have all the prompt info available to you. Oh yes, the methods for getting prompt info aren't documented either, heh. But they are:

my_avatar.getStatus() - returns the "exb.." part of the prompt
my_avatar.getHealth() - returns the last health value
my_avatar.getMana() - returns the last mana value
my_avatar.getEgo() - returns the last ego value
my_avatar.getPower() - returns the last power value.
Unknown2005-01-30 21:29:17
...And that's why I don't use MUSHClient. wink.gif

Unknown2005-01-30 21:50:01
Heh, I don't use Zmud for a number of reasons, but I won't list them because it'd probably take several pages.



In all seriousness though, the snippet you posted for Zmud does essentially the same thing (or it could with some additions), but the one above for Mushclient (while not being the fastest possible way to do it) does it all in one pass - no need to add anything more to it. Had you wanted to track every single letter in the status line, plus save all the prompt values in variables for reuse, you'd have to add another 7-8 lines of if statements? Which would bring you to a total of 10-11 lines, as opposed to only 6 in my script. tongue.gif So Mushclient still wins in brevity.