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


Joined: 21 Jan 2005
Posts: 99
Location: Solvang, CA

PostPosted: Mon Jul 17, 2006 2:49 am   

%replace / %remove replace and removing too much
 
In the following trigger:
Code:
#ac {%d%s{@TallyTarget}%s%w%s%d%s(*)%s%d%s}

I am attempting to capture a formatted number that can range from between 1 and 2.147bil. The trigger works properly, and (in the test I ran it on) captured the number "365,365,365". Now I wanted to divide that number by 200,000, so I attempted to strip the commas out. I tried it two ways, and got the same result both times:
Code:
%remove( ",", %1)
%replace(%1,",","")

In both cases, the result returned with "365" only. I tried using the remove/replace commands in staight eval math, in an addkey command, and in a #va command, the result was the same every tme. I also tried variations of %-1, {%1}, {%-1}, etc. My question is:

Do I need to change my trigger into 4 seperate triggers, looking for "%d" "%d,%d" etc? Or more specifically, do I need to change my trigger to accomodate my purposes? Or am I just doing something wrong with the syntax of %remove/%replace, or missing another function altogether? Thanks in advance :)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jul 17, 2006 5:58 am   
 
you need to use quotes around %1. It looks counter-intuitive, but %1...%99 are substituted early on in the process.

Also of note, %n matches comma-delimited numbers, and does in fact remove them from the number.
_________________
EDIT: I didn't like my old signature
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