Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
hojotrolloc
Beginner


Joined: 08 Jun 2008
Posts: 14

PostPosted: Sat Jan 05, 2013 7:05 pm   

Need help with a math trigger
 
So the mud outputs;

Your base abilities are: Str:18 Int:14 Wil:14 Dex:14 Con:12.

and I want it to show;

Your base abilities are: Str:18 Int:14 Wil:14 Dex:14 Con:12. 72

I do mostly coloring and targeting scripts, not to good at math...

Code:
#CLASS {MyStatSum}
#VAR StatSum
#TRIGGER {Your base abilities are: Str:%1 Int:%2 Wil:%3 Dex:%4 Con:%5.} {#add str %1;#add int %2;#add wis %3;#add dex %4;#add con %5}
#MATH StatSum %1+%2+%3+%4+%5
#TRIGGER {Your base abilities are: Str:%1 Int:%2 Wil:%3 Dex:%4 Con:%5.} {#SUBST "Your base abilities are: Str:%1 Int:%2 Wil:%3 Dex:%4 Con:%5 @StatSum"}
#CLASS 0


So this isnt working the way I want. Anyone feel like helping a fool out?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jan 05, 2013 9:10 pm   
 
1)you don't need two triggers, put what they both do in just one
2)in your pattern, don't use %1...%99, use proper wildcards as they will self-limit based on what they will match. Since you are only dealing with integers, use %d.
3)surround your math operation in ()--ie, (%1+%2...)
4)no need for the #ADD commands, unless you want to keep a running total of how much of each stat was rolled across multiple rolls.
_________________
EDIT: I didn't like my old signature
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Jan 05, 2013 11:59 pm   
 
Too bad this isn't CMUD. I'd have suggested using #SAYADD instead of #SUB.

Code:
#TRIGGER {^Your base abilities are: Str: (%d) Int:(%d) Wil:(%d) Dex:(%d) Con:(%d).$} {#SUB {Your base abilities are: Str:%1 Int:%2 Wil:%3 Dex:%4 Con:%5 - %eval(%1+%2+%3+%4+%5)}}


Try that. It should be the only trigger you need. I anchored it so that it matches the start and end of the lines, so I'm hoping it's all on one line.
Reply with quote
hojotrolloc
Beginner


Joined: 08 Jun 2008
Posts: 14

PostPosted: Sun Jan 06, 2013 9:04 am   
 
Thanks a ton guys!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net