Equilibrium and balance and stuff.

by Archthron

Back to Mechanic's Corner.

Archthron2005-08-31 00:43:35
Alright. So, you know how in the prompt it has the equilibrium, balance, prone, deaf, and so forth in letters that go on and off. Well, I made a really big class that has a trigger for each possible combination, but it's really big, may be slowing me down, and now I need to change a major part of it, so instead I'm just going to ask:

How do you capture the entire thing with just one trigger? I know there's a way, I've seen it here before, but don't know what to search for to find it. Any help would be appreciated.
Unknown2005-08-31 01:12:59
(%d)h, (%d)m..... (%d)w -
Unknown2005-08-31 01:22:32
You can make a regular expression trigger, which I recommend for more accuracy and speed.

CODE
#REGEX {^(\\d+)h, (\\d+)m.+?(*)-} {#var Health %1;#var Mana %2;#if (%pos("e", "%3")) {#var Equilibrium 1} {#var Equilibrium 0}...} "" {nocr|prompt}


Hope that gives you a good idea. It's just off the top of my head, so don't quote me on this literally when you code it and test it.
Gwylifar2005-08-31 01:54:16
I always just captured it as a word and then checked for the characters I cared about with something like %pos().
Unknown2005-08-31 04:44:05
Gwyls way is good:

^(%d)h, (%d)m, (%d)e, (%d)p (%w)-
{#var health %1... #var bal %5}
Whenever you wanna check balance or eq, do #IF (%pos(e,@bal)) {blah} {Notblah}
Unknown2005-08-31 10:27:04
My pattern does the same thing, but with a more specific pattern. The prompt flags will all be captured to a single word. You could break it down further and have the values saved directly to variables even, but that's a bit of overkill and would require different checks than most systems are used to making (i.e., "e" and "" versus 1 and 0).

CODE
(?eq:e?)(?bal:x?)


Aren't regular expressions fun?
Archthron2005-08-31 19:54:49
Hmm... ok, I'm still kind of confused. I only need the equilibrium and balance part too by the way. Can someone tell me, How does the %pos function work? The help files were confusing, as I can't figure out how to use the output.
Terenas2005-08-31 19:58:38
This is what I use, and it works well for me.

#REGEX {^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (+)} {#va health %1;#va mana %2;#va endurance %5;#va promptcheck %7;#if (%pos( e, @promptcheck)) {#var eq 1} {#var eq 0;#va able 0};#if (%pos( l, @promptcheck)) {#va lbal 1} {#va lbal 0;#va able 0};#if (%pos( r, @promptcheck)) {#va rbal 1} {#va rbal 0;#va able 0};#if (%pos( x, @promptcheck)) {#var balance 1} {#var balance 0;#va able 0};#if (%pos( d, @promptcheck)) {#var deaf 1} {#var deaf 0};#if (%pos( b, @promptcheck)) {#var blind 1} {#var blind 0};#if (%pos( p, @promptcheck)) {#var proned 1} {#va proned 0};#if (%pos( k, @promptcheck)) {#var kafe 1} {#var kafe 0};#if @proned=0 {paralysis=0} {#va able 0};#if @balance=1 {#if @eq=1 {#if @rbal=1 {#if @lbal=1 {#if @proned=0 {#va able 1}}}}}} "" {nocr|prompt}

The rbal and lbal are only really useful for a warrior obviously, but the format is still similar if you want to add any other prompt, such as Psi channels.
Archthron2005-08-31 20:10:03
I notice you don't variablize your ego, power and will. Interesting. Anyways, I think I've got it figured now. Thanks for your help, everyone!
Terenas2005-08-31 20:14:53
Yeah, I find it rather trivial to capture those 3, health and mana is important for auto sip and tracking certain things, but those 3 are pointless.
Gwylifar2005-09-01 13:53:59
pBalanceLeftArm = %bitand(%pos("l",%7),1)
pBalanceRightArm = %bitand(%pos("r",%7),1)
pBalanceEquilibrium = %bitand(%pos("e",%7),1)
pBalanceGeneral = %bitand(%pos("x",%7),1)

That's the most efficient way I found to do it.
Ekard2005-09-01 15:19:02
QUOTE(Gwylifar @ Sep 1 2005, 03:53 PM)
pBalanceLeftArm = %bitand(%pos("l",%7),1)
pBalanceRightArm = %bitand(%pos("r",%7),1)
pBalanceEquilibrium = %bitand(%pos("e",%7),1)
pBalanceGeneral = %bitand(%pos("x",%7),1)

That's the most efficient way I found to do it.
177216



Is this faster then

#if (%pos( e, %7)) {#var eq 1} {#var eq 0}

??
Gwylifar2005-09-01 16:01:55
Nominally. Try both in a loop 1000 times and see. It is on my machine, but only slightly; however, the difference is probably greater if you don't have as much processing power as I do.

This syntax can also be used in more places (like in an %if() or within a @function definition) without it getting too hairily complex.