need help with stat tracker in prompt

by Unknown

Back to Mechanic's Corner.

Unknown2006-12-07 23:04:05
I'm trying to track my stats in my prompt. I have gauge buttons set up, and have some code to print out whether I've lost or gained hp, mana, ego. It all sort of works, except there is one big problem. The gauges don't reset, nor do the message print, until the next prompt is received. To clarify: the messages for the last prompt print out only before the current prompt, but not until the current prompt is received, or some other text is received.

It's something like this:
100h, 100m, 100e, 10p, 1000en, 1000w ex-

50h, 100m, 100e, 10p, 1000en, 1000w ex-

HP -50
50h, 100m, 100e, 10p, 1000en, 1000w ex-

The #show doesn't print until I press enter or some other text is received. Why?! I'm thorougly confused and could use some help. My code looks like this:

CODE
#TRIGGER {(%d)h, (%d)m, (%d)e, %dp, %den, %dw %w~-} {
@prevHp = @currentHp
@prevMana = @currentMana
@prevEgo = @currentEgo
@currentHp = %1
@currentMana = %2
@currentEgo = %3
#IF {@currentHp > @prevHp} {#SHOW H +%eval( @currentHp - @prevHp)} {}
#IF {@prevHp > @currentHp} {#SHOW H -%eval( @prevHp - @currentHp)} {}
#IF {@currentMana > @prevMana} {#SHOW M +%eval( @currentMana - @prevMana)} {}
#IF {@prevMana > @currentMana} {#SHOW M -%eval( @prevMana - @currentMana)} {}
#IF {@currentEgo > @prevEgo} {#SHOW E +%eval( @currentEgo - @prevEgo)} {}
#IF {@prevEgo > @currentEgo} {#SHOW E -%eval( @prevEgo - @currentEgo)} {}
}
Soll2006-12-07 23:14:28
The following should do the trick. Using SHOW adds a newline after each echo, which will be infinitely spammy. #echop attaches it to the line and doesn't add a new one at the end, so you'd get something akin to:

QUOTE

50h, 500m, 100e, 10p, 1000en, 1000w ex- H -50 M -50


Which I just feel is neater. The '{nocr|prompt}' bit at the end means it fires off of the prompt, and not off of a new-line. (Or something. smile.gif )

CODE

#TRIGGER {(%d)h, (%d)m, (%d)e, %dp, %den, %dw %w~-} {
@prevHp = @currentHp
@prevMana = @currentMana
@prevEgo = @currentEgo
@currentHp = %1
@currentMana = %2
@currentEgo = %3
#IF {@currentHp > @prevHp} {#ECHOP H +%eval( @currentHp - @prevHp)} {}
#IF {@prevHp > @currentHp} {#ECHOP H -%eval( @prevHp - @currentHp)} {}
#IF {@currentMana > @prevMana} {#ECHOP M +%eval( @currentMana - @prevMana)} {}
#IF {@prevMana > @currentMana} {#ECHOP M -%eval( @prevMana - @currentMana)} {}
#IF {@currentEgo > @prevEgo} {#ECHOP E +%eval( @currentEgo - @prevEgo)} {}
#IF {@prevEgo > @currentEgo} {#ECHOP E -%eval( @prevEgo - @currentEgo)} {}
} "" {nocr|prompt}
Unknown2006-12-07 23:20:00
Ah, I was wondering what that {nocr|prompt} thing meant in other people's code.
I tried it and it works. Thanks so much for the help!
Unknown2006-12-07 23:43:24
And don't use "@var = value"... It's kludged to make it work in zMUD, but it's not intended to be coded that way. Drop the @ when assigning a variable this way. (Tip: the @var = value syntax will not work this way in CMUD.)