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
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 1:20 pm   

trigger help
 
i have been trying to get a trigger, and for some reason i am stumped.
i know it should be simple to make work.

what i am wanting to do is to automatically depsoit my gold to my home bank when the ammount excedes a set amt of gold. lets say for now the ammount is 100,000.

here is the mud output as you pick up each pile of gold.

You now have 7,582 gold pieces.

i have been trying to accomplish the task like this:
pattern
You now have (%d) gold pieces.
value
if (%d) >100000
home deposit (%d)

please excuse my newbieness in advance :)

*takes note of the mass laughter in the background*
Reply with quote
malathion
Beginner


Joined: 23 Jul 2004
Posts: 20

PostPosted: Sat Dec 31, 2005 3:08 pm   
 
oops


Last edited by malathion on Sat Dec 31, 2005 3:14 pm; edited 1 time in total
Reply with quote
Kiasyn
Apprentice


Joined: 05 Dec 2004
Posts: 196
Location: New Zealand

PostPosted: Sat Dec 31, 2005 3:11 pm   
 
#TRIGGER {You now have (*) gold pieces.} {#IF (%eval(%replace(%1,",",""))>100000) {home deposit %replace(%1,",","")}}
_________________
Kiasyn
Owner of Legends of Drazon
Coder on Dark Legacy
Check out Talon, an easy IMC connection.
Reply with quote
malathion
Beginner


Joined: 23 Jul 2004
Posts: 20

PostPosted: Sat Dec 31, 2005 3:13 pm   
 
double posted


Last edited by malathion on Sat Dec 31, 2005 3:13 pm; edited 1 time in total
Reply with quote
malathion
Beginner


Joined: 23 Jul 2004
Posts: 20

PostPosted: Sat Dec 31, 2005 3:13 pm   
 
You're right. It looks like a variable with a , in it would be evaluated as a character string, so the evaluation goes to the one with more characters in it.
Reply with quote
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 3:21 pm   
 
excellent , thanks bunches.
Reply with quote
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 3:54 pm   
 
hrmm cant get it to work, it only wants to deposit the first 3 digits
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Dec 31, 2005 4:36 pm   
 
#HELP Pattern Matching
#HELP #IF

pattern:
You now have (%n) gold pieces.
value:
#IF (%1 >100000) {home deposit %1}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 5:17 pm   
 
i need to look further into more variables , the comma in 122,456 is throwing stuff off

You now have 328,116 gold pieces.
home deposit 328

is best i can get so far.
Reply with quote
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 5:59 pm   
 
#IF (%eval( %replace( %1, ",", ""))>100) {home deposit 100000)}

You now have 330,527 gold pieces.
home deposit 100000

since i could not get it to recognise the comma i set the >to 100 and only deposit a set ammount , and it doesnt try to deposit when balance is below 100k now so all is well . i doubt if the (%eval stuff is needed in there this way but im leaving it alone since it works :P.

thanks for the help all
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Dec 31, 2005 6:32 pm   
 
Hello Am I chopped liver here?

%n matches +,-, and commas and then strips the commas

I tested it, I know it works, and its why there is a %n in the first place.
_________________
Zmud Support Library
Zmud Knowledge Base

Last edited by nexela on Sat Dec 31, 2005 6:38 pm; edited 2 times in total
Reply with quote
atlasmud.com
Newbie


Joined: 08 Nov 2005
Posts: 7
Location: missouri

PostPosted: Sat Dec 31, 2005 6:34 pm   
 
it didnt work on mine , have no clue why

although ill try it again , to make sure i didnt mess something up when i entered it

You get 100 gold coins.
You now have 499,800 gold pieces.
home deposit 499800
(9857h 9906m)You deposit 499,800 gold to home bank.
(9857h 9906m)*** DUEL *** Nicon taunts, "mirei your still mounted"
(9857h 9906m)*set c lucifer gold 100000
Lucifer has 100000 gold.
(9857h 9906m)get go
You get 100 gold coins.
You now have 100,100 gold pieces.
home deposit 100100

evidently it did work , i just didnt notice it, on my mortal character with all the lines whizzing by. thanks
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sun Jan 01, 2006 9:20 pm   
 
Quote:
%n match a number that starts with a + or - sign


From Pattern Matching.

You guys just need to put quotes around the %1 when you use it in a function, then it works like a charm... bloody commas.

Edit: Here's how I would do it.

Code:

#REGEX {^You now have ([0-9,]+) gold pieces\.$} {
  goldpieces = %subregex( "%1", ",", "")
  #if (@goldpieces >= 100000) {home deposit @goldpieces}
  }


Which uses an extra variable, which is theoretically a little bit faster (fewer runs through the substitution) and can be used elsewhere.
Reply with quote
malathion
Beginner


Joined: 23 Jul 2004
Posts: 20

PostPosted: Mon Jan 02, 2006 12:55 am   
 
Nexla it does not strip the commas. It just evaluates based on which string has more characters in it, which is probably why it seemed to work in your test case, but it actually didn't.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Jan 02, 2006 1:41 am   
 
#TRIGGER {TEST: (%n)} {#ECHO %1;#IF (%1>10000) {#SAY Greater then 10k} {#SAY Less then 10k}}

#SHOW TEST: 1,000
1000
Less then 10k

#SHOW TEST: 10,000
10000
Less then 10k //because 10k isnt more then 10k :P

#SHOW TEST: 10,001
10001
More then 10k

#SHOW TEST: 123,456,789
123456789
More then 10k

#SHOW TEST: 500
500
Less then 10k

#SHOW TEST: -500
-500
Less then 10k

#SHOW TEST: -500,000
-500000
Less then 10k

#SHOW TEST: +500,000
+500,000
more then 10k
_________________
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