|
ErrorDetected Newbie
Joined: 10 Jan 2006 Posts: 1
|
Posted: Tue Jan 10, 2006 11:49 pm
newbie trigger help with if |
Okay, so I'm a complete newbie to zMUD scripting, I know the most basic commands, and I've been trying to wade through the help files and forums for something that might help. I won't feel bad if you point me to relevant help files or threads, but here's what I'm trying to do:
When I use an ability to see mana on a MUD, I want it to color the line if the mana is 50% or less than maximum, and send an alias to the MUD aswell if it is 50% or less. The only thing is, that I only want it to send the alias if the person I'm using the ability on is a target. (@tar)
For example..
@tar = Jack
Jill's mana stands at 100/200.
would color the line green but not send the alias "smp".
Jack's mana stands at 97/200.
would color the line green and send the alias smp.
So basically I'm only trying to figure out how to use percentages in if triggers, sorry if I made it overly complex, and I am considerably new to zMUD coding.
Thanks! |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Jan 11, 2006 4:58 am |
Look up Pattern Matching in the helpfiles if you are stumped on how to create the trigger patterns, but to work with percentages you can use the %float() function:
#if ((%float(%1) / %2) < .5) {} {}
Normally, the mathematical operators use integer math, which means that any fractions are simply dropped off the result (1 / 3 = 0 or blank, instead of the expected .334). By using the %float() function, you force zmud to use floating-point math, which keeps the decimal. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Slaem Apprentice
Joined: 20 Sep 2005 Posts: 135
|
Posted: Wed Jan 11, 2006 5:30 am |
#TR {^%w mana stands at &%n{tcmp}~/&%n{tmmp}.$} {#CW green;#IF (%eval(@tcmp*100/@tmmp)<50) {smp}}
|
|
|
|
|
|