|
ScrappyJ Newbie
Joined: 09 Oct 2005 Posts: 1 Location: Charlotte, NC
|
Posted: 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
} |
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Slaem Apprentice
Joined: 20 Sep 2005 Posts: 135
|
Posted: 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}
|
|
|
|
|
|
|
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
|
|