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


Joined: 19 Nov 2003
Posts: 16
Location: USA

PostPosted: Wed Apr 26, 2006 1:40 am   

Help with Trigger Capturing
 
I'm trying to capture the plant, herb count, harvester name, and amount from the following example:


H:319 M:414 E:1498 W:1974 <eb> lastharvest

Plant Herb Count Harvester Date Amount
---------------------------------------------------------------------------
A lovage plant 51 Skye 8/4/490 14
H:319 M:414 E:1499 W:1974 <-b>


This is my trigger pattern.

#trigger {^*{@plant}*%s(&%dplantleft)%s(%w)*(%d)} {#say Harvester - %3 - Amount - %4}


However, the amount is incorrect. It's only displaying a 1 digit number. When it's 14, it displays a 4. When it's 27, it displays a 7. How can I fix it to correctly show the amount? Thanks.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Apr 26, 2006 2:34 am   
 
change the last * to %d/%d/%d.

Also, the &varname syntax also counts as part of the %1...%99 lineup so there's no need to provide parentheses.
_________________
EDIT: I didn't like my old signature
Reply with quote
Risca
Beginner


Joined: 19 Nov 2003
Posts: 16
Location: USA

PostPosted: Wed Apr 26, 2006 2:39 am   
 
I don't need the date. I just want to capture the right Amount. In my example of 14, All I get is the number 4. Not the whole 14.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Apr 26, 2006 3:51 am   
 
Quote:

change the last * to %d/%d/%d.


I already told you HOW to change your pattern. Because you apparently don't believe me, here's WHY. The last * you have in your pattern is matching too many characters. * matches whitespace, numbers, letters, and symbols that are not used as special characters in ZMud. Thus, you need to stop using * and go with something more specific.
_________________
EDIT: I didn't like my old signature
Reply with quote
Risca
Beginner


Joined: 19 Nov 2003
Posts: 16
Location: USA

PostPosted: Wed Apr 26, 2006 4:54 am   
 
I didn't understand what you meant, but then realized it after my reply and got it to work. Thanks.
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Wed Apr 26, 2006 2:24 pm   
 
you only capture when you do (%d) doing a %d just lets zmud know there is a number, but it is not stored.
1 2 3 4 5
(%d) (%d) (%d) (%d) (%d)
%1 = 1
%2 = 2
%3 = 3
%4 = 4
%5 = 5

1 2 3 4 5
%d %d %d %d %d
%1 =
%2 =
%3 =
%4 =
%5 =
_________________
http://www.Aardwolf.com
Reply with quote
Risca
Beginner


Joined: 19 Nov 2003
Posts: 16
Location: USA

PostPosted: Thu Apr 27, 2006 4:23 am   
 
Thanks for the tip. I'll be sure to remember that. On another note, I ran into another problem with the same script.

Code:
#TRIGGER {^*{@plant}*%s(&%dplantleft)%s(&%wharvester_name)%s%d/%d/%d%s(&%dlastharvest_amount)} {#ECHO @lastharvest_amount and @plantleft and @plant;#IF ((@harvester_name = "Risca") and (@lastharvest_amount < @plantleft)) {#math pristine_amount (@plantleft-@lastharvest_amount)/2;#IF (@goal > @pristine_amount) {goal = @pristine_amount}};#IF ((@harvester_name = "Risca") and (@lastharvest_amount > @plantleft)) {goal = 0}} "autoharvester"


Here's the output:


H:319 M:414 E:1499 W:1974 <eb> lastharvest

Plant Herb Count Harvester Date Amount
---------------------------------------------------------------------------
A quince tree 60 Airamaya 1/18/490 15
A flax plant 31 Risca 9/5/490 31
A endive vine 54 Risca 9/6/490 7
31 and 54 and endive
H:319 M:414 E:1499 W:1974 <-b>

*Bold part is the echo.

The problem is that the variable, lastharvest_amount, is suppose to be 7, not 31. However, it's taking the number from the previous line with the amount of 31. Any help would be appreciated. Thanks!
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Thu Apr 27, 2006 8:48 pm   
 
Without seeing the whole script i can only guess what you are trying to do

Code:

#CLASS {autoharvester}
#VARIABLE plant {quince}
#VARIABLE harvester_name {Airamaya}
#VARIABLE lastharvest_amount {15}
#VARIABLE plantleft {60}
#TRIGGER {^%w%s(&plant)%s%w%s(&plantleft)%s(&harvester_name)%s%d/%d/%d%s(&lastharvest_amount)} {
  #IF ((@harvester_name = "Risca") and (@lastharvest_amount < @plantleft)) {
    #MATH pristine_amount (@plantleft-@lastharvest_amount)/2
    #IF (@goal > @pristine_amount) {goal = @pristine_amount}
    }
  #IF ((@harvester_name = "Risca") and (@lastharvest_amount > @plantleft)) {goal = 0} {}
  #ECHO @lastharvest_amount and @plantleft and @plant
  }
#CLASS 0
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