 |
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: Sat Nov 22, 2008 11:22 pm
Self-Expanding pattern? Storing variables in %1-%99? |
Hey guys, tryin to come up with a trigger/pattern that stores everything in a line to %1-%99.
Pattern.
You also see a copper coin, some bronze coins, a field goblin, a thin field goblin, a musk hog, a musk hog and a field goblin.
You also see a dour field goblin, a copper coin, some bronze coins, a field goblin, a thin field goblin, a musk hog and a field goblin.
You also see a musk hog.
You also see a throwing hammer topped with a snarling lion's head and a low wall.
You also see a spotted field goblin and a beady-eyed field goblin.
So basically I need a pattern that can add everything before a "," before "and" and before "." And it needs to be able to expand and detract from anywhere of 1 variable to 10. etc
Thanks :) I've been tryin to figure this one out for awhile, I can use something like this for numerous applications in my mud.
-Haldrik |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Nov 23, 2008 4:05 am |
#trig {You also see (*).} {$things=%replace(%1," and",",");$things=%replace($things,", ","|");#var Stuff $things}
should do it. The idea is that you remove the " and " from the string and replace it with ", " so it looks like all the other items, then replace all the ", "s with "|", which make it a stringlist. You can do #print @stuff after running one of those test lines to see what I mean. |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Nov 23, 2008 6:59 am |
1)look for " and " instead. Not including the word boundary will cause %replace() to do some unintended things since it doesn't incorporate word-boundary functionality.
2)keep in mind that there are a lot of complex items that make it impossible to tell the difference between:
You also see a throwing hammer topped with a snarling lion's head and a low wall. <-- two items, the throwing hammer and the wall
You also see a throwing hammer topped with a snarling lion's head and a low wall. <-- one item, the throwing hammer with the lion and wall as dependants.
This is an annoying feature of DR formatting, but I can definitely guarantee that things only get more obnoxious from this point.
3)if you are trying to maintain an up-to-date item list, be aware that there are tons of item messaging you have to account for (it's a lot more than you think) |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: Mon Nov 24, 2008 3:58 am |
Great, I'm going to test it out shortly!
Matt-
What did 1) mean? are you talking about " and " vs fangs " and"? If so... roger :)
As for what I'm doing, I'm trying to build my room monitor a bit more efficiently. Before when I counted the items/mobs, I would make multiple triggers for every item that would be in the room, and I would enable the trigger on Roomname and disable the trigger on obvious exits. Now, if i can do it all in 1 trigger, it seems like it would be a lot easier on me.
Plus this same exact problem can be used for the DIR system to make a nice slow walk. Which im also stoked about.
And yes... I'm quite aware how obnoxious DR can be. But, thats ok. It's fun figuring stuff out. :) Sometimes I think its more fun to build stuff in CMUD for dragonrealms then it is actually playing.
Lol :) |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Nov 24, 2008 5:10 am |
Using " and " rather than " and" will cock up this script. You'll need to change the %replace to %replace(%1," and ",", ") if you do that. Hopefully it's clear why - if you don't, there won't be a space after the comma and thus the second replace won't catch it.
|
|
|
|
 |
Haldrik Wanderer
Joined: 03 Sep 2007 Posts: 88
|
Posted: Mon Nov 24, 2008 11:05 am |
fang-
Bloody genius! :)
It works like a charm. I love it.
Thanks! |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Nov 24, 2008 10:32 pm |
I say " and " because of obscure references like andreshlew (floating/mobile merman island), andu (in-game name of a time unit), and so forth. It's sometimes a pain to figure out how an item goes back together again so you can fix the script.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
|
|
|