Re: HP line evaluation
"Joshua M. Berne" <berne-7iHiS5+6wm7SUeElwK9/[email protected]> Mon, 5 Jul 2004 02:34:54 -0400 (EDT)
| Newsgroups | gmane.comp.games.mud.client.lyntin |
|---|---|
| Message-ID | <[email protected]> |
The multiple %s is proabbly your best way to go. The good news is that
the performance shouldn't really be hit too hard, it breaks down to just
one regexp regardless of how complicated the action trigger is.
As to processing it, you're stuck now with dealing with legacy -tin
syntax. The best bet when that gets too complicated is to switch over to
python. For that you can do
#action {HP[%1/%2] SP[%3/%4]} {#processhp {%1} {%2} {%3} {%4}}
Then write a quick python module like so:
#!/usr/bin/env python
import exported, modules.modutils
commands = {}
def processhp_cmd(session, args, input):
hp = args["hp"]
maxhp = args["maxhp"]
if (1.0 * hp) / maxhp < 0.5:
exported.lyntin_command("tell notadragon HELP ME PLEASE!!!")
commands["processhp"] = (processhp_cmd,"hp maxhp sp maxsp")
def load():
modules.modutils.load_commands(commands)
def unload():
modules.modutils.unload_commands(commands.keys())
Then just drop that somewhere. Depending on what your hp bar shows you
might have to do some more processing on the arguments, but it will be WAY
easier to do in python than with lyntin #ifs and whatnot.
This is also 3.3-specific in how it registers the commands.. so you'll
have to tweak if you're on 4.0+.
On Mon, 5 Jul 2004, Jim Sanders wrote:
> Sorry if this is posted in the wrong place, and I'm sure this is a
> stupid question, but what's the best way to do an evaluation of an
> hpbar? As a brief example:
>
> HP[100/100] SP[100/100]
>
> There are actually several more entries including some that include
> dotted decimal notation with a % sign inside brackets
> [100.00/100.00%]. What I want to do is evaluate each entry and as an
> example, if hp is less than maxhp (in this case, say HP [90/100]),
> evaluate another entry on the line and if its more than say 50.00%, do
> some command. Then, if that other entry falls below 50.00%, do
> another command.
>
> I'm pretty new at lyntin and at python, so the only way I can think of
> to do this is to do an action with like:
>
> HP[%1/%2] SP[%3/%4]
>
> However, this would drag it out to 10+ variables and just make things
> ugly trying to put all the if statements and such on one line. Also,
> I'm guessing it might hurt performance as well. I'm wondering if
> someone could point me in the right direction to get this to work.
> Not looking for exact command lines, just the best way to approach it.
> I figure this will be a good learning experience, but not sure where
> to start.
>
> Thanks for any help,
>
> Jim
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Lyntin-devl mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lyntin-devl
>
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com