|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Tue Sep 28, 2010 4:33 am
Help with trigger. |
In this mud the quest master sends me on a quest for multiple different items. I would like to create a trigger that will capture all of the items stores them to a temp variable of some type, and checks the room for a patter match, if there is a match then remove that item from the list. My cmud skills are not very good, and I was hoping to get some help.
String to match
%1 tells you 'Look for a %w somewhere in the vicinity of*
%w can be a string with multiple values, but always one of about 20. the trick here is that I cant pick up %w.
So for example :
Jimmy tells you 'Look for a scroll of the world's history somewhere in the vicinity of Turn in the cave!'
%w = scroll of the world's history.
pick up %@questItem does not work since it sends the whole string. But in this instance pick up scroll works. Any idea how to handle this? |
|
_________________ <Clever text here> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue Sep 28, 2010 4:44 am |
Best idea would be to figure out how many different quest items there are and match the strings to some keys in a record variable, so, for instance:
scroll of the world's history
would be matched to scroll
Where they key is: scroll of the world's history
And the value is: scroll
When the pattern matches you can make a trigger to %db( @name_of_db_var, $var_from_pattern)
And it will send the keys to grab the pattern. Unless, of course, there's just too many different possible quest items to record them all.
If you give me more info, I'll consider making this for you. What I need:
- All possible quest items (their strings and the keys to pick them up)
- An example of a full phrase of the quest master listing off items
- An example of an item laying on the ground |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Tue Sep 28, 2010 5:28 am |
Thank you for the offer, I want to get better, so I am going to play with it some tomorrow. If I get stuck I will give you what you need.
|
|
_________________ <Clever text here> |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Tue Sep 28, 2010 4:40 pm |
Here is where I am at, I have a var with the name of the quest items @questItems
and a data base with the a Name field, and a PickUp field.
and a trigger in its own class called MatchQuest
Code: |
<trigger priority="2000" id="118">
<pattern>*({@questItems})*</pattern>
<value>%db(@questItems,PickUp)
#T- MatchQuest |
right now for some reason the value of the trigger does not send anything, but if I enter that line into my mud it sends the correct command. Am I missing something? |
|
_________________ <Clever text here> |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Sep 28, 2010 7:52 pm |
You cannot start a command line with a %function or @variable. You must start it with a command. In this case, you want to use #SEND %db(@questItems,PickUp)
The #SEND command will send its argument to the mud. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue Sep 28, 2010 8:59 pm |
Yup, apologies for not clarifying that. I simply meant that %db() would give you the keys you needed if you arranged it properly, but you'll always need to submit it into something like a #SEND, besides, you need to preface it with "get" anyways, no?
#SEND %concat( "get ", %db(stuff, stuff)) |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Wed Sep 29, 2010 5:14 am |
I see what the problem is but I am not sure how to fix it. When i search the database for the value of the quest item I seem to be searching for the whole list the really long string that makes up the list of quest items.
To try and get around that I added a local variable, key, but it is still being set the value of the whole list, rather then just the one item.
Code: |
<trigger priority="330" id="33">
<pattern>*@questItems*</pattern>
<value>$key= @questItems
#SEND %concat( "get ", %db($key, PickUp))
</value>
</trigger>
|
|
|
_________________ <Clever text here> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 29, 2010 12:10 pm |
CMUD should be able to search through a "really long list" rather easily, you won't need to use any #IF or #SWITCH statements for it. You shouldn't need to at least. If you make the quest item shorts (not the keys, but what you see come up) into the key values for the record variable, you can use that in the trigger pattern (as you're doing) in order to get a match. Now, the neat thing about CMUD trigger patterns (this was true in zMUD too) is that you can "capture" variable aspects about them by surrounding what you want to capture in parentheses. So, in this case, we would surround the variable. It should also be noted that because the variable is a list, we'll want the surround it in {} too, this basically turns it into an appropriate "OR" matching pattern.
So, based upon what you gave us in your first post, this is what I would use for a pattern. Bear with me, I tend to use REGEX instead of zscript for patterns:
Code: |
%w+ tells you 'Look for a ({@questItems}) somewhere in the vicinity of*
|
This will give us a %1 equal to the value of the short description of the item we want. We can store that in a variable and use it in a later trigger to match the item as it's lying on the floor. I would try to match the pattern better than simply surrounding the variable in wild-cards, but won't be able to do so personally without more information on the possible match, so I will simply use your pattern for now:
Notice that I didn't use {} or your other variable there. This would be the variable that you store the current quest item in for your quest. If you are, in fact, questing for more than one item at a time, it can easily be turned into a string list, just remember to use {}. If it's turned into a stringlist, you'll also want to make sure to use %1 to refer to the value instead of the variable. From there, using:
Code: |
#SEND %concat( "get ", %db(@QuestItemDB, %1))
|
Should grab the keys for you every time, assuming you've setup the database variable properly.
[/code] |
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Wed Sep 29, 2010 3:03 pm |
First, thank you for explaining this process to me, its really helpful. I have made a few adjustments this morning and I am still getting some strange results in its current form.
The database is named: Items ( I plan to extend this to selling loot items later on)
The database has two fields currently : Name : GetCmd
This part works perfectly for inserting values into the questItems list
Code: |
%w tells you 'Look for a ({@questItems}) somewhere in the vicinity of*
|
however this part of code confuses me
Code: |
#SEND %concat( "get ", %db(@QuestItemDB, %1))
|
When I was looking at the documentation for %db
So considering the database structure the key should be GetCmd, and the record I am looking for is %1, or the match from the string list.
Code: |
<trigger priority="2000" id="118">
<pattern>*({@questItems})*</pattern>
<value>#SEND %concat( "get ", %db(%1, GetCmd))
</value>
</trigger>
|
So the problem with this is that with the trigger either everything (in and out of the list) is matched, or nothing is matched. Which leads me to believe that maybe you can not use a list variable as the match line in the trigger. The reason I set it up this way to begin with is other then the name of the item, nothing else exists on that line. There is nothing else to trigger off. Also I played with the matter mater in the trigger wizard, but it was little help
|
|
_________________ <Clever text here> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 29, 2010 3:47 pm |
Are you setting up an actual database for this? I'd probably just suggest using a record variable than a whole database. Also, if the line is just the quest items, then you shouldn't need * at all, just use the variable surrounded by parentheses.
Quote: |
So the problem with this is that with the trigger either everything (in and out of the list) is matched, or nothing is matched.
|
What do you mean? If everything is working as described, it should only match what's in that variable, I can't see how that would be a problem. Once again, I think this boils down to a lack of communication. I need more information in order to properly help you. I can understand wanting to do this for yourself, but it makes it difficult to help on our end. I promise if you give me information I will work with you to get this done, and make sure you understand everything I put into it. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Sep 29, 2010 5:28 pm |
Btw, you don't need to use %concat. The following will work fine:
Code: |
#SEND {get %db($key, PickUp)} |
Remember that {} acts just like " quotes except it allows the expanding of variables and functions. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 29, 2010 5:58 pm |
Ah, thanks Zugg. I've been using %concat() a lot more now since you've been trying to shy away from implicit concatenation, but I've also known that using {} has been long suggested and I have simply avoided it (sorry!) I'll try to implement that more in a lot of my scripts so that I remember to suggest it to potential scripters ;)
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Wed Sep 29, 2010 6:45 pm |
Got it!! I was doing it all backwards thank you so much for the help, my trigger ended up looking like this.
Code: |
<class name="QuestMatch" id="32">
<trigger priority="330" id="33">
<pattern>({@questList})</pattern>
<value>#SEND {get @getQuest.%1}
</value>
</trigger>
</class>
|
Now that its working I will start to tweak it so that every time I collect the quest item on the ground it removes it from the list, and when the list is empty the class is disabled until something is added to the list again.
I did not realize that there was a record variable, originally I wanted to use something like a 2d array, but the closest thing to that type of structure I knew about was the database. After I read your comment chamenas, I noticed the drop-down field, supper cool.
Before what I meant with it matched everything was that by placing *'s on either end of the @list it was matching EVERYTHING, like gibberish, letters, numbers, symbols excreta. For what ever reason with that combination of wild-cards it did not matter what was in the list itself. Either way its all good now =) |
|
_________________ <Clever text here> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 29, 2010 7:14 pm |
I'm glad you got it working. Let me know if I can help further.
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Thu Sep 30, 2010 5:24 am |
This afternoon I tricked out my trigger to also handle items for sale, when I look at my inventory with a specific alias command it will place the "known" items into lists that are relevant to where the items can be sold, so a list of weapons and a list of armor, ect. My question for you is how long can these "know" lists get, in the case of the questHelper its only about 20-25 items, but when it comes to weapons potentiality I could be dealing with hundreds, even thousands. (Im adding them as I encounter them).
|
|
_________________ <Clever text here> |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Thu Sep 30, 2010 1:23 pm |
There is no real limit for the length of string lists or database variables. People have successfully used lists and database variables with many thousands of elements.
|
|
|
|
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Thu Sep 30, 2010 2:36 pm |
Ahh sweet, thanks.
|
|
_________________ <Clever text here> |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Sep 30, 2010 4:10 pm |
My Clan Highlighter is at 2500 records and growing.
|
|
|
|
|
|