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
g61828
Beginner


Joined: 21 Nov 2003
Posts: 12
Location: USA

PostPosted: 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
Reply with quote
GaidinBDJ
Wanderer


Joined: 15 Nov 2002
Posts: 52
Location: Las Vegas, Nevada

PostPosted: 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
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: Sat Jun 11, 2005 1:53 pm   
 
#TRIGGER {^You have ([%d,]) gold coins.$} {get cash bag;deposit %subregex("%1",",","");put cash bag}
Reply with quote
GaidinBDJ
Wanderer


Joined: 15 Nov 2002
Posts: 52
Location: Las Vegas, Nevada

PostPosted: 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
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: 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.
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Maelstrom
Apprentice


Joined: 10 Feb 2005
Posts: 158

PostPosted: 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 =)
Reply with quote
GaidinBDJ
Wanderer


Joined: 15 Nov 2002
Posts: 52
Location: Las Vegas, Nevada

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Jun 12, 2005 8:54 pm   
 
[%d%p]
_________________
Discord: Shalimarwildcat
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Jun 12, 2005 10:23 pm   
 
%n works for me for comma'd numbers

you could always try %x if %n isnt working
_________________
Zmud Support Library
Zmud Knowledge Base
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