Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Thu Nov 13, 2008 11:55 am   

Param exclusions using a stringlist?
 
pattern:
Code:
({%%dbkeys({@gemlist})})

trigger:
Code:
#var glist %additem( %1, @glist)



Here is my problem:

@gemlist has :

amber
stone
bloodstone



stone is triggering off bloodstone. I tried the verbatim check mark in trigger but it didnt work.
Normally I would do something like stone{^bloodstone} but not sure how to make it work with the list. I dont even entirely understand how it works now, sometimes I have to switch the side to make it work. i.e. stone{^bloodstone} or {^bloodstone}stone.

Also, "chamber" causes amber to fire as well.


Thanks!
-Haldrik
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Nov 13, 2008 2:11 pm   
 
Is @gemlist a record variable or a stringlist? You seem to be describing it as a stringlist, but you wouldn't use %dbkeys on a stringlist. I think you need to tell us a bit more about what you are trying to do with this code. From what you say, I would guess that you need to modify your trigger pattern, but we don't have enough information to help you fix that. What lines from the mud is this supposed to fire on?
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu Nov 13, 2008 2:15 pm   
 
Umm, why use %dbkeys when you have simple String list?

Code:

<window name="untitled">
  <uid>{189D4896-7EAC-4B2B-A43D-3D30FD973F19}</uid>
  <packages>untitled</packages>
  <var name="gemlist" type="StringList" id="1">stone|amber|bloodstone</var>
  <trigger priority="20" id="2">
    <pattern>%q({@gemlist})%q</pattern>
    <value>#say Works.</value>
  </trigger>
</window>


Above's the code I did in untitled session based on your info. Key for the pattern is to use "%q".
That is word boundary (I think that's how it's called?), which means that everything *inside* the string list will be captured
with this pattern, but not for instance when it's "bloodstoneofmotherofearth" instead of just "bloodstone".

Hopefully this made some sense. Still haven't had my morning coffee.
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Thu Nov 13, 2008 3:10 pm   
 
Lets see...


@gemlist is a stringlist. I'm using %dbkeys because that was the only command i knew to trigger off a list :)

Basically what is happening is... I kill the mob, and it drops any number of items on the ground. I then "look" and turn my itemground trigger on. It then picks up every item from @gemlist and stores it into @glist.

At that point I pick the items up using a loop and alias...
Code:
#loop %numitems(@glist) {itemtemp = %item(@glist, 1);stow %pop(@glist);#wait 1000}


As for the simple string list... I have no idea what that is. But I'm very interested to know.


Also as for your code... i'm not sure exactly how to have CMUD do that. I mostly do everything through the default trigger window. But, I'm very good at looking at code and figuring out how it works(or at least applying it somewhere else).

So if you wanted to explain a bit about the code you posted, I would love to hear it :)


Hopefully this helped shed some light.


Here are some in game examples:


You search the faenrae reaver.
It carried some reinforced greaves, a battle axe.
You also find a small rock crystal, 2 bronze coins, 5 copper coins.

>look

[Silverwater Mines, Tunnel]
The floor of this bell-shaped room is smooth and level and so free of debris that it warrants suspicion. An arching roof of smooth rock flies up overhead, fading off into the cave's natural darkness. A pale greenish light from the north fills the cavern partially, becoming gradually watered down and consumed as it tries to reach south. You also see some copper coins, some bronze coins, a small rock crystal and some junk.
Obvious exits: north, southwest.
>stow coin

You pick up 5 copper Lirums.
>stow coin

You pick up 2 bronze Lirums.
>stow crystal

You pick up a small rock crystal.
You put your crystal in your shoulder tote.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Nov 13, 2008 4:00 pm   
 
%dbkeys() is used to convert the keys of a record variable into a stringlist. If you already have a stringlist, you don't need to do that.


What Progonoi was basically suggesting was to put %q before and after the capture to indicate the word boundary. The %q will match any punctuation, so adding that in will prevent it from matching longer words with those strings inside them. His code was just an example showing that it works. All you need to do is make your trigger pattern be:
Code:
%q({@gemlist})%q


You might still have problems if you have things like 'crystal' and 'super-crystal' in them, with a hyphen or other punctuation inside the word next to a word which is also a member of the stringlist. If you do, let us know. We can come up with a more complicated pattern to eliminate that problem too.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 13, 2008 11:18 pm   
 
Technically %q doesn't match punctuation, but it's what you want to use in this case. Rahab's pattern should be just what you need.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Fri Nov 14, 2008 6:54 am   
 
Awesome.

Yea, i borrowed my %dbkeys from an actual databse trigger list i was using. :P Hooray for not knowing exactly what I'm using!


%q sounds great. I'm going to plug it in asap.

But going for beers now. :)


Thanks guys.
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Sat Nov 15, 2008 5:32 am   
 
Hey!

%q %q is working great. I was hoping to refine exlusions even more.


You also see some copper coins, some bronze coins, a small star diopside and some junk.


You also see a pair of emerald earrings, some copper coins, some bronze coins and a wind hound.


Ok, so those are 2 examples of my patterns.



I have "emerald" in my string list to pick up. Yet, emerald is not a key for earrings. So basically I need it to ONLY trigger off a keyword that has a comma after it, or and.

A pair of emerald earrings, Should trigger earrings, and not emerald.


Should i just do something like...

Code:
{%q({@gemlist})%q,|%q({@gemlist})%q and}



Let me know what ya think :)

Edit: The above didn't work, i just tested it. Bummer :P
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Nov 16, 2008 9:08 pm   
 
You also want the possiblity of a period. Perhaps this:
Code:

%q({@gemlist}){,|.| and }
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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