Health/Mana/Ego Bars

by Unknown

Back to Mechanic's Corner.

Unknown2007-12-07 05:29:55
In case any other newbies are having trouble with this (like myself):

The reason Health works and not the others is because of spacing. The current code only checks for one space after the text:

#TRIGGER {Health : (%d)/(%d)} {maxhealth=%2}
#TRIGGER {Mana : (%d)/(%d)} {maxmana=%2}
#TRIGGER {Ego : (%d)/(%d)} {maxego=%2}

The actual score screen looks something like this:

| Health : 885/924 Endurance : 3360/3360 Power : 0p
| Mana : 725/1020 Willpower : 3840/3840 Reserves : 0%
| Ego : 800/1164 Mindset : Cautious Esteem : 0%

As you can see, "Mana" and "Ego" have more spaces until the colon. To account for this, add the (%s) pattern (which matches any number of white spaces). Because you have an extra pattern in the expression, you also have to bump up the value of the storing variable to 3:

#TRIGGER {Health (%s): (%d)/(%d)} {maxhealth=%3}
#TRIGGER {Mana (%s): (%d)/(%d)} {maxmana=%3}
#TRIGGER {Ego (%s): (%d)/(%d)} {maxego=%3}
Unknown2007-12-07 11:58:53
You can simplify them a little bit and not capture things you don't really want into the system variables. In other words, you have a %1 and %2 that you never use. Also, you can use ^ to anchor it at the beginning of a line and use ~ to escape the | symbol.

CODE
#TRIGGER {^~| Health :%s%d/(%d)} {maxhealth=%1}
Gwylifar2007-12-07 19:34:57
The variable number of spaces is after the colon, not before.

CODE
#TRIGGER {^~| Health :%s%d/(%d)} {maxhealth=%1}