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
ScrappyJ
Newbie


Joined: 09 Oct 2005
Posts: 1
Location: Charlotte, NC

PostPosted: Mon Oct 10, 2005 4:46 pm   

Remove the , from 12,345 when read by a trigger.
 
I'm trying to read some numbers from my prompt with a trigger but the numbers have commas in them. So first off I have to use * to get it to begin with. Then I try to say #var gold %remove(",", %2), if it read 12,345 for %2 then gold would be 12. I tried a couple things like %literal, %quote and they don't seem to work. I think what is happening is it is expanding %2 so its doing %remove(",",12,345) instead of %remove(",", "12,345").

How would I be able to read that from my prompt and store it in a variable without the comma?

What I have now:

Code:

#TRIGGER {<(*)g (*)xp (*)tnl>$<(%d)/(%d)hp (%d)/(%d)m (%d)/(%d)mv>} {
#var gold %replace(%1, ",")
#var xp %replace(%2, ",")
#var tnl %replace(%3, ",")
#VAR hp %4
#VAR maxhp %5
#VAR mp %6
#VAR maxmp %7
#VAR mv %8
#VAR maxmv %9
}
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Oct 10, 2005 5:34 pm   
 
This one is fairly straightforward. Simply quote the %1 when you use the %replace function, ie

Code:
#var gold %replace("%1", ",")


instead of

Code:
#var gold %replace(%1, ",")
_________________
Asati di tempari!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Oct 10, 2005 8:27 pm   
 
Use %n, that matches comma-delimited integers (ie, "12,345" but not "12,345.67"). If you aren't dealing with decimals, %n will strip the commas for you, resulting in a regular integer.
_________________
EDIT: I didn't like my old signature
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Mon Oct 10, 2005 8:37 pm   
 
#TRIGGER {~<&%n{gold}g &%n{xp}xp &%n{tnl}tnl~>$~<&%nhp/&%n{maxhp}hp &%nmp/&%n{maxmp}m &%nmv/&%n{maxmv}mv~>} {#NOOP}
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
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