 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Sat Nov 01, 2008 1:00 pm
%find, is there a better way? |
Hey all. Ok, so what I'm trying to accomplish here is a reputation tracker that gets stored in the database. My guild is a guild that deals with many different material types, and each time you use a skill involving a material, you gain rep for that material. You can then go to the guild hq and see how close you are to 'leading' that material. For the most part, I accomplished what I wanted, but the issue seems to be with using %find because sometimes material names are inside of eachother, like 'tin' is in 'platinum' and 'aluminium' is inside 'duraluminium'...so when I go to view my rep in my DB, some come up as having 0 rep or the wrong rep.
| Code: |
#TRIGGER {^You are the current %1 leader~!} {#DBPUT %find( %1, MerchRep) {%Leads=100}} "reptracker"
#TRIGGER {^You feel like being (%d)~% as good as the current %1 leader, (%w).} {#DBPUT %find(%2,MerchRep) {%Leads=%1}} "reptracker"
#TRIGGER {^You have no experience with %1, unlike %2, the current leader.} {#DBPUT %find(%1,MerchRep) {%Leads=0}} "reptracker"
|
Note that my use of %1, as nasty as it is, is because some materials are two words, like 'moss agate' and 'neo burlap'.
Some examples to trigger from:
You are the current cesium leader!
You have no experience with neo burlap, unlike Marvin, the current leader.
You feel like being 49% as good as the current mithril leader, Beanos.
If someone could please help with this or give me some ideas, I would appreciate it, thanks. :) |
|
|
|
 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Sun Nov 09, 2008 4:08 am |
What I'm asking is there a better way to refine looking for something in the database I suppose.
|
|
_________________ Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org) |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 10, 2008 2:16 pm |
I believe your triggers are wrong. You do not use %1 within the pattern of a trigger. Rather, you use parentheses, (), to mark the things that you want stored in %1, %2, etc. Without checking the rest of the code, your trigger patterns should be:
| Code: |
#TRIGGER {^You are the current (*) leader~!} {#DBPUT %find( %1, MerchRep) {%Leads=100}} "reptracker"
#TRIGGER {^You feel like being (%d)~% as good as the current (*) leader, (%w).} {#DBPUT %find(%2,MerchRep) {%Leads=%1}} "reptracker"
#TRIGGER {^You have no experience with (*), unlike (*), the current leader.} {#DBPUT %find(%1,MerchRep) {%Leads=0}} "reptracker"
|
|
|
|
|
 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Mon Nov 10, 2008 3:19 pm |
Even if it was sloppy code (which I have long since cleaned up), that isn't the issue. I know how to match patterns. The issue is that when looking through the database with %find, since I listed all the materials in alphabetical order when I created the records, when you use %find, it will always list the records in alphanumerical record order. So in order to solve my problem, I ended up doing it the long way, using %item(%numitems(%1)) to use use the last item of the list.
|
|
_________________ Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org) |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 10, 2008 6:32 pm |
I gave the previous response because it was a very obvious problem with your code. I did not try to answer your question about %find because I don't do much with cmud databases.
Now that I've looked at the documentation a bit more, it looks like you need %query instead of %find. You don't give enough information about the structure of your database, so I don't know the name of the first field. But it would be something like:
%query(%concat("&FirstField = ",%1), MerchRep) |
|
|
|
 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Mon Nov 10, 2008 6:43 pm |
Well I had tried query previously like that, and it doesn't seem to support 2-word material names, like 'enchanted air' or 'neo burlap'...produces a null result. %find allowed me to do that. Though, query seemed to solve one problem, but create another.
|
|
_________________ Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org) |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 10, 2008 9:40 pm |
You probably need to quote the two word phrase. Something like this:
%query(%concat("&FirstField = '",%1,"'"), MerchRep) |
|
|
|
 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Tue Nov 11, 2008 12:45 am |
sigh, this is getting nasty. :(
|
|
_________________ Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org) |
|
|
 |
Tarken Aurelius Apprentice

Joined: 23 Oct 2008 Posts: 120 Location: Cincinnati, Ohio
|
Posted: Wed Nov 12, 2008 1:41 am |
No that doesn't seem to do it either :( Oh well
|
|
_________________ Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org) |
|
|
 |
|
|
|
|
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
|
|