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
Kurt_DH
Wanderer


Joined: 26 Oct 2000
Posts: 62

PostPosted: Thu May 01, 2003 12:20 am   

Question
 
If I wanted to turn 15,000 into a variable I could use for math operations, like 15000, how would I do that?
Basically I just want the commas stripped from the number so I could use the number itself for operations.
Reply with quote
Lain
Novice


Joined: 26 Oct 2001
Posts: 38

PostPosted: Thu May 01, 2003 12:58 am   
 
If you're capturing the 15,000 from mud output, you can use - %n

For example,

Pattern: You have (%n) pennies.
Value: #VAR money %1

Lain
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu May 01, 2003 5:50 pm   
 
You can do this by combining %replace() to remove the commas and %number() to convert the string to a number.
#VAR temp1 {15,000}
#MATH temp2 {%number(%replace( {@temp1}, ",", "")) + 27}

@temp2 equals 15027.
Both functions are needed, as can be seen with a little experimentation.
Without %number() @temp2 equals 1500027.
Without %replace, @temp2 equals 27.
Without either, @temp2 equals 15,00027.

As Lain said, you can use %n in trigger patterns to avoid all this.

LightBulb
Advanced Member
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