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
blkno1
Novice


Joined: 26 May 2002
Posts: 30
Location: USA

PostPosted: Sun Apr 24, 2005 11:55 am   

Help with trigger please
 
This is the output from the mud

A tiny blue imp wearing large horn-rimmed spectacles pops in and reads from a ledger:
7 a green potion
1 a menthol potion
3 a deep blue potion
For a grand total of 11 potions.

I want to populate the following vars from it.

@potion1 = green
@potion2 = menthol
@potion3 = deep blue
etc

Would like to do up to 5 potions.
Im working on it now, just wanted to get this post out first. Thanks
-bk Rolling Eyes
Reply with quote
...{chris}...
Novice


Joined: 11 Apr 2005
Posts: 31
Location: Yucaipa, Ca

PostPosted: Sun Apr 24, 2005 5:19 pm   
 
Code:

#class potion
#tr {%1 a green potion} {#add green %1}
#tr {%1 a menthol potion} {#add menthol %1}
#tr {%1 a deep blue potion} {#add deepblue %1}
#tr {For a grand total of %1 potions.} {#add totalpot %1}
#alias showpot {#show %ansi(high,red)@green - %ansi(high, white)Green Potions! %ansi(high,red)@menthol - %ansi(high, white)Menthol potions!, %ansi(high,red)@deepblue - %ansi(high, white)Deep Blue Potions!, %ansi(high,red)@total - %ansi(high, white)Total Potions!
#class 0

Does this help any? What else do you need for this, besides counting?


***NOTE*** To the advanced scripters, Im a newbie to scripting, is this a proper way of doing it?
_________________
My signature is better than yours.
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Sun Apr 24, 2005 5:55 pm   
 
You should use %d or %n to capture numbers instead of %1. %1 is not a correct wildcard variable to use in trigger patterns.
Reply with quote
...{chris}...
Novice


Joined: 11 Apr 2005
Posts: 31
Location: Yucaipa, Ca

PostPosted: Sun Apr 24, 2005 6:06 pm   
 
How would you set it up then....
#tr {%d a green potion} {#add green %d} ?

Ive always used %1-%99.

-Chris
_________________
My signature is better than yours.
Reply with quote
blkno1
Novice


Joined: 26 May 2002
Posts: 30
Location: USA

PostPosted: Sun Apr 24, 2005 6:42 pm   Trigger Help
 
My bad, I should have been more clear in my first post.

Mud output...

Quote:
A tiny blue imp wearing large horn-rimmed spectacles pops in and reads from a ledger:
7 a green potion
1 a menthol potion
3 a deep blue potion
For a grand total of 11 potions.


The color of the potion is going to change. Above are just examples. What I am trying to do is poplulate a series of button with quaff @potion1, etc depending on what the mud outputs. So with the folowing mud output I would then have 3 buttons with quaff green, quaff menthol, etc. All the buttons and stuff I can do. Just trying to get the VAR values from the mud output. Hope this helps.

-bk
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Apr 24, 2005 7:29 pm   
 
Quote:

How would you set it up then....
#tr {%d a green potion} {#add green %d} ?

Ive always used %1-%99.


You have to use %1...%99 in the code portion of your settings (that would be the unbolded portion of the above trigger). For trigger patterns (the bold part) you have to use special wildcards. This is explained in the help file under the topic of Patern Matching.

So, the trigger would look like this:

#trigger {(%d) a green potion} {#add green %1}

Now for the #ADD part. Are you adding what the imp says to what you already have in inventory (ie, a buying script), or is the imp telling you all of what you do have? If it's the latter, you probably want to replace #ADD with #VARIABLE:

#VARIABLE green %1
_________________
EDIT: I didn't like my old signature
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Apr 24, 2005 7:47 pm   
 
#TRIGGER "potion_start" {^A tiny blue imp wearing large horn-rimmed spectacles pops in and reads from a ledger:} {potions="";#T+ potion_capture}
#TRIGGER "potion_capture" {^(%d) a (*) potion} {#ADDKEY potions {%2} {%1}}
#TRIGGER "potion_end" {^For a grand total of (%d) potions.}

This uses a Data record but because the KEY might have spaces you have to use it like this

#SAY %db(@potions,"deep blue")
instead of #SAY @potions.deep blue //this is an example of how to retrieve a regular data record variable value
or even #SAY @potions //this is an example of how to retrieve a regular variable value
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
blkno1
Novice


Joined: 26 May 2002
Posts: 30
Location: USA

PostPosted: Mon Apr 25, 2005 4:22 am   What I have so far.
 
First off, thanks for all the help from everyone. Thats why I love these forums, everyone is sooo helpful. Thanks again. Laughing

Here is what I have thus far, that seems to work ok.

Mud Output

Code:
A tiny blue imp wearing large horn-rimmed spectacles pops in and reads from a ledger:
   11   a green potion
    1   a tan potion
    1   a magenta potion
For a grand total of 13 potions.



Code:
#CLASS {Potion_Pushers}
#VAR totalpotions {13}
#VAR pcount {1}
#VAR potion1 {green}
#VAR potion3 {magenta}
#VAR potion4 {}
#VAR potion5 {}
#VAR potion2 {tan}
#TRIGGER {^For a grand total of (%d) potions.} {
  #var totalpotions %1
  #T- potion_trigger
  #var pcount 1
  }
#TRIGGER {^A tiny blue imp wearing large horn-rimmed spectacles pops in and reads from a ledger:} {#T+ potion_trigger}
#BUTTON 44 {@potion1} {
  get @potion1 pocket
  quaff @potion1
  } {} {} {} {} {} {} {} {} {} {} {} {62} {} {} {} "" {} {} {} {3}
#BUTTON 45 {@potion2} {
  get @potion2 pocket
  quaff @potion2
  } {} {} {} {} {} {} {} {} {} {} {} {62} {} {} {} "" {} {} {} {3}
#BUTTON 46 {@potion3} {
  get @potion3 pocket
  quaff @potion3
  } {} {} {} {} {} {} {} {} {} {} {} {62} {} {} {} "" {} {} {} {3}
#CLASS 0
#CLASS {Potion_Pushers|potion_trigger}
#TRIGGER {(%d) a (%a) potion} {
  #VAR potion@pcount %2
  #MATH pcount (@pcount+1)
  }
#CLASS 0


Seems to work okay, but Is therea more efficient way of doing this?

-bk
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 25, 2005 11:53 pm   
 
Well, for starters, do you use the @potion1...@potion5 variables anywhere else besides this script? If not, you can get rid of those and just type the words into the button captions. Your @pcount variable can then be modified into a data record variable along lines that Nexela laid out.
_________________
EDIT: I didn't like my old signature
Reply with quote
blkno1
Novice


Joined: 26 May 2002
Posts: 30
Location: USA

PostPosted: Tue Apr 26, 2005 11:32 am   
 
Well the types of potions are going to change all the time so thats why I wanted to just use the @potion1 for button label. As for the data record thingy Im going to have to do some reading, Its new territory for me in Zmud scripting. Confused

Thanks for the input

-bk
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