|
g61828 Beginner
Joined: 21 Nov 2003 Posts: 12 Location: USA
|
Posted: Sat Jun 11, 2005 11:16 am
Need some help with a var in a trigger |
Ok. So basically I want to be able to type in the command gold which brings up how much gold my char has. Then I want to store that number into a VAR, pull out my cashcard from my bag, deposit the gold, then put the cashcard back into my bag. So here goes.
428hp 761m 146mv> gold
You have 100,000 gold coins.
Thats what I get from the gold command. Now the part I'm having trouble with. The trigger I have is this..
#TR {You have %1 gold coins.} {get cash bag;deposit %1;put cash bag}
However this is what happens..
428hp 761m 146mv> gold
You have 100,000 gold coins.
get cash bag
deposit 100,000
put cash bag
428hp 761m 146mv> You get a cashcard from a bag.
428hp 761m 146mv> You deposit 100 coins.
428hp 761m 146mv> You put a cashcard in a bag.
Now, from what I can see, either the VAR only does the numbers before the comma or the mud doesn't recognize the numbers after the comma. So, the comma has to go. How? Thats basically what I need.
D |
|
|
|
GaidinBDJ Wanderer
Joined: 15 Nov 2002 Posts: 52 Location: Las Vegas, Nevada
|
Posted: Sat Jun 11, 2005 12:19 pm |
Yea, I had problems with recognizing comma delimited numbers. I eventually had to write multiple triggers
#TRIGGER {You have %1 gold coins.} {#var cash %1; ... }
#TRIGGER {You have %1,%2 gold coins.} {#var cash [(%1*1000)+%2]; ...}
#TRIGGER {You have %1,%2,%3 gold coins.} {#var cash [(%1*1000000)+(%2*1000)+%3]; ...} |
|
_________________ Barry
Gaidin @ 3k.org |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Sat Jun 11, 2005 1:53 pm |
#TRIGGER {^You have ([%d,]) gold coins.$} {get cash bag;deposit %subregex("%1",",","");put cash bag}
|
|
|
|
GaidinBDJ Wanderer
Joined: 15 Nov 2002 Posts: 52 Location: Las Vegas, Nevada
|
Posted: Sat Jun 11, 2005 4:09 pm |
Wow, Maelstrom. That darn #REGEX is so sweet. That's gonna cut my triggers in half (my MUD uses alot of comma delimited values). Sweet.
|
|
_________________ Barry
Gaidin @ 3k.org |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sat Jun 11, 2005 5:50 pm |
Why not just use the correct pattern matching wildcard %n.......
This is super simple!
#TRIGGER {^You have (%n) gold coins.$} {get cash bag;deposit %1;put cash bag}
The pattern matching page is a GREAT refrence. |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Sat Jun 11, 2005 6:08 pm |
Heh, I knew about %n but did not know it would take care of the commas.
Your right, thats better =) |
|
|
|
GaidinBDJ Wanderer
Joined: 15 Nov 2002 Posts: 52 Location: Las Vegas, Nevada
|
Posted: Sun Jun 12, 2005 7:51 pm |
Hrm...%n didn't work for me for comma delimited numbers. It didn't recognize comma delimtied numbers. Guess I'll have to play aroudn with that.
|
|
_________________ Barry
Gaidin @ 3k.org |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sun Jun 12, 2005 8:54 pm |
[%d%p]
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Jun 12, 2005 10:23 pm |
%n works for me for comma'd numbers
you could always try %x if %n isnt working |
|
|
|
|
|