|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Sat Aug 17, 2002 10:28 pm
Comma delimited lists |
Below is an excert from the quick-who list of a very popular MUD (Achaea).
When I type 'qw' I want my script to capture every name in this list. The list continuses for an unknown number of lines until it is terminated by a known name (mine) and a full stop.
Tuxxy, Gelphend, Laigha, Janduin, Derec, Laylana, Wes, Trunks, Ottis, Puck,
Gondor, Cosmos, Dace, Aramil, Pip, Dorrin, Jorus, Nephele, Azshara, Wendigo,
Krel, Xophe, Hamel, Hakeshuu, Kookluk, Blazian, Seigfreid, Viperda, Zenokail,
I would like the names to be put into a StringList (@whoList) so that when I walk into a room and someone with stupid huge name is there (and some of these name run for three lines), it will highlight the actual names.
When all else fails - there is always running away to fall back on.
---> Burser |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Aug 17, 2002 11:37 pm |
#AL qw {#VAR qw {};#T+ qw;~qw}
#TR {^%w, %w,} {#VAR qw {@qw %trigger}} {qw}
#TR {Zenokail.$} {#T- qw;makelist} {qw}
#AL makelist {#LOOP %numwords("@qw", ", ") {#ADDITEM names {%word("@qw", %i, ", ")}}}
LightBulb
Senior Member |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Sun Aug 18, 2002 5:04 am |
Fantastic!
That works almost perfectly.
Only three alterations - and simple ones.
In the makelist alias, you have put quotes arround @qw - these break the alias
You also need to put in a names=%null command to reset the list everytime I qw.
Thank you so much!
When all else fails - there is always running away to fall back on.
---> Burser |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Aug 18, 2002 3:48 pm |
I had quotes around @qw to avoid problems with having commas in the function. I probably should have used {@qw} instead.
I didn't put names=%null because I didn't see any point in starting from scratch every time. Clearing @names means you will only have the names of the people who happened to be on the last time you did qw, not clearing @names will allow you to build up a better list over time.
LightBulb
Senior Member |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Sun Aug 18, 2002 5:41 pm |
Hmm - good plan. Thats why I'm the one asking for help and you're the one giving it :)
There is one last problem.
Rasteon, Obzidian, Chrystalline, Emyrld, Telluar, Gwana, Tarkhaat, Gordon, Kumi
, Avialle, Vardoulacha, Kahless, Maylin, Baldazar, Dre, Midgard, Lepida, Jetol,
Senans, Bircilak, Infurnus, Gavriel, Ysbaddaden, Brennanb, Jeasaw, Elsp, Sanka,
Sometimes the list runs right to the end, and the comma appears on the next line. Is it possible to do a trigger that will fire on {^%w, %w,} and {^,%w,%w}?
And while I'm at it, will the {^%w, %w,} trigger if the line runs:
Bob, Stuart.
Or will I miss the name Bob?
Once all thats sorted out I've finaly got a weapon against people with massive names
When all else fails - there is always running away to fall back on.
---> Burser |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Aug 18, 2002 11:28 pm |
If your name is always last, then there should always be at least two names on every line unless the only name is yours. If somebody does come up with a name that's long enough to require an entire line, you'll have to add it to the list yourself. So, let's plan on two names minimum per line but remove the second comma since the second name might be yours. A second trigger will handle the lines that start with a comma.
#TR {^%w, %w} {#VAR qw {@qw %trigger}} {qw}
#TR {^, %w, %w} {#VAR qw {@qw %trigger}} {qw}
#AL makelist {#LOOP %numwords({@qw}, ", ") {#ADDITEM names {%word({@qw}, %i, ", ")}}}
LightBulb
Senior Member |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Mon Aug 19, 2002 3:04 am |
I'd buy you a beer, but the Atlantic is in the way.
Thanks!
---> Burser
|## - The flags have it. |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Mon Aug 19, 2002 3:58 am |
Right - I'll make that two beers if you can help me with this next bit. Its odd.
Here is the trigger I've got to spot someones name from the list we've now got in @names
#TRIGGER {%e[1;36m(*)} {#FORALL @names {#IF ((%pos( %i, %1)) > 0) {#ECHO %i}}} "" {notrig|color}
It detects the ANSI colour code for bold cyan, then looks through those lines for names in the @names variable, bouncing back to me names that it finds. This seems to work, the trigger will echo people names back to me.
Apart from when it decides that {#IF is a good thing to spam the mud with.
Dracunos points off into the wild blue yonder.
1410h, 1770m ex-say I remember when there used to be wild blue yonders all over the hills.... you don't see them very often now
You say, "I remember when there used to be wild blue yonders all over the
{#IF
{#IF
hills.... you don't see them very often now."
1410h, 1770m ex-{#IF
{#IF
{#IF
{#IF
That yellow is awful, but the colour is nescicary (and almost accurate. imagine that the blue is the bold cyan).
Why does that trigger above, spam the MUD like this? Like most MUD players I respect my MUD, and hate the thought of suddenly launching an un-solicited DoS attack on the poor thing.
---> Burser
|## - The flags have it. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Aug 19, 2002 4:38 am |
If I had to guess I would say it is a bad character in the names variable itself. All your braces and paranthesis line up on the trigger you showed. Although from the scripts written by Lightbulb in this thread I can not see how any problem character would have gotten in there.
In either case, because %1 is used to capture a multiple word string it should be enclosed in quotes. That alone may fix the problem. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Aug 19, 2002 7:13 am |
I can't see anything specific in your trigger (or in any of mine) to cause this. That {#IF is usually a symptom of an unpaired {. It appears from the placement and number that it might be the periods causing the problem, although I'm not sure how.
It might be easier to just avoid the problem though.
#TR {({@names})} {#ECHO {%1}}
LightBulb
Senior Member |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Mon Aug 19, 2002 12:49 pm |
The only characters other than text in the @names variable are the occasional space before a name (I'm looking into stopping that) and tht full stop after my name.
The trigger which uses the stringList is new to me, I didn't know you could do that (*mental note). However, it only triggers once per line, and sometimes there are two names per line.
The stringList trigger also seems to be picking up names captured to other widows >=)
I may need to put some ANSI triggers in there.
I've reverted back to my old trigger, because lots of times there are multiple names on one line. It works for a while, and then on some unknow trigger it goes monkey poo.
This always happened during a say. Is there someway of making it trigger when there is a cyan line without the word 'says' in it?
Would it run a little like this:
#TRIGGER {%e[1;36m(*)(^says)(*)} {#FORALL @names {#IF (%pos( %i, %1) > 0) {#ADDITEM inRoom %i}}} "" {notrig|color}
---> Burser
|## - The flags have it. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Aug 19, 2002 10:24 pm |
#TRIGGER {^%e[1;36m} {This should trigger on all HiCyan lines} {} {color}
LightBulb
Senior Member |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Tue Aug 20, 2002 1:30 am |
I know that *grin*
I've sorted out the ANSI stuff, I knew how to do that.
What the main problem is is the loop trigger.
I have to check the entire line, so I can't do it with the #TR {(@names)} trigger.
I use the ANSI trigger:
#TRIGGER {%e[1;36m(*)} {#FORALL @names {#IF ((%pos( %i, %1)) > 0) {#ECHO %i}}} "" {notrig|color}
It works for a few times, but it gets confused with says (which are also HiCyan).
If it were possible to trigger on any HiCyan line that DOESN'T have the word 'says' in it... that would be fantastic.
I've never got a {^says} trigger (or similar to work like I want it too.
---> Burser
|## - The flags have it. |
|
|
|
Burser Wanderer
Joined: 07 Feb 2001 Posts: 70 Location: United Kingdom
|
Posted: Tue Aug 20, 2002 1:50 pm |
I've tried everything I can think of to stop the loops spamming the MUD with {IF.
I'm begining to think its a bug. Should I clutter the Beta forums with it?
---> Burser
|## - The flags have it. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Aug 20, 2002 4:58 pm |
#TRIGGER {%e[1;36m(*)} {#IF (%pos("says",{%1})) {#NOOP} {#FORALL @names {#IF ((%pos( %i, {%1})) > 0) {#ECHO %i}}}} "" {notrig|color}
I've already said that I don't know the cause of the {#IF problem. All your {'s appear to be matched with }'s. However, you are using * to capture a line which includes "'s and ,'s and other punctuation, then tossing it into functions without using delimiters. As Vijilante pointed out, simply adding delimiters may cure the problem.
Personally, I would use the MUD commands to change the color of the "says" channel. I'd also be more likely to use #CW to highlight the names within the line rather than #ECHO to put them on a separate line.
Using the beta forum for its intended purpose (reporting problems with beta software) is not "clutter".
LightBulb
Senior Member |
|
|
|
|
|
|
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
|
|