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


Joined: 05 Dec 2003
Posts: 3
Location: USA

PostPosted: Tue Dec 09, 2003 4:07 pm   

Get Integer data from string with comma separators
 
Alright, i think i saw the answer to this, elsehwere in these forums, but i cant for the life of me find it again.

Anyways, I'm trying to capture data from my prompt, and the mud i play in uses commas to separate large numbers, at thousands, millions, etc.

A typical prompt is this, given my server-side settings:

<Stats: hp 949 mhp 949 gd 4,528,804 al 998 tim night ma 414 mam 414 mv 530 mvm 530 xp 77,634,071 xpn 5,714,929 sty S we 404 wem 999
CharName:

Yeah, i know it's long, but it provides me all the info i could need. The first line, before charname, is displayed as black on black, and gagged, as well.

Anyways, the parts i'm worried about, are "gd 4,528,804" (current gold amount), "xp 77,634,071" (experience total) and "xpn 5,714,929" (ecperience required until next level).

I have the following trigger set to capture this prompt data.

#TRIGGER {<Stats: hp &hpvar mhp &hpmax gd &goldvar al &alignvar tim &timevar ma &manavar mam &manamax mv &movvar mvm &movmax xp &expvar xpn &expneed sty &styvar we &weivar wem &weimax} {#gag}

The following variables result (in this case) for @goldvar, @expvar, and @expneed.

#VAR GOLDVAR {4,528,804}
#VAR EXPVAR {77,634,071}
#VAR EXPNEED {5,714,929}

Now, the question is:

How can i rewrite this trigger, or add additional triggers, to store these variables as integers, without commas, rather than as strings, with commas?

Thanx in advance,
Spott (aka Glithoniel)
Reply with quote
Toetag
Magician


Joined: 10 Oct 2000
Posts: 356
Location: USA

PostPosted: Tue Dec 09, 2003 4:30 pm   
 
%replace function:

#VAR GOLDVAR {%replace( "4,528,804", ",", "")}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Dec 09, 2003 6:39 pm   
 
Use the %n wildcard and the #VARIABLE command.
#TRIGGER {<Stats: hp &hpvar mhp &hpmax gd (%n) al &alignvar tim &timevar ma &manavar mam &manamax mv &movvar mvm &movmax xp (%n) xpn (%n) sty &styvar we &weivar wem &weimax} {#gag;#VAR GOLDVAR %3;#VAR EXPVAR %10;#VAR EXPNEED %11}
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