|
Belial Beginner
Joined: 14 Jun 2006 Posts: 12
|
Posted: Wed Jun 14, 2006 2:06 pm
Capture |
Hi,
I am trying to create a list of the players online. I searched the forums and came up with something like:
#TRIGGER "who" (*) {#VAR who_online {@{who_online}%1}}
#TRIGGER {] Players*} {#T+ who;#VAR who_online {%1}}
#TRIGGER {in the Realms right now.} {#T- who}
The output of the mud looks like this:
--------------------------------------------------] Players [-------------------------------------------------
playera playerb playerc playerd playere playerf
playerg playerh playeri playerj playerk
-----------------------------> There are eleven players in the Realms right now. <----------------------------
I am obviously doing something wrong as the variable is empty who_online is empty.. ;).. The patterns seem to match.
I guess there are two questions.. How do I make the trigger to understand it should start capturing on the row below and....
Since all the players are seperated with spaces how do I make it so each player is a seperate string.. variable{playera|playerb|playerc} etc.
Thanks in advance
Best regards |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Wed Jun 14, 2006 2:48 pm |
You need three triggers.
First
Code: |
^--------------------------------------------------\] Players \[-------------------------------------------------
#Variable Who_Online {}
#Trigger+ {Player name storer} |
Another trigger that rips the names that has to have Id:Player name storer
Code: |
\b(\a+)
#AddItem Who_Online {%1} |
And finally a trigger that disables the capturing.
Code: |
^-----------------------------> There are \a+ players in the Realms right now\. <----------------------------
#Trigger- {Player name storer} |
Note: If the disabling capture triggers id is wrong, the middle trigger will continue capturing every word there is, thus you have to get the ID's right or it wont work. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
Belial Beginner
Joined: 14 Jun 2006 Posts: 12
|
Posted: Wed Jun 14, 2006 3:33 pm |
Now we are actually getting somewhere, thanks BlackSmith.. However it only captures the first names on each row (in this example player A and G)
(the enabling and disabling is all good).
Best regards |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Wed Jun 14, 2006 10:37 pm |
enable the
[x] Prompt
from triggers options for the second trigger. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
Belial Beginner
Joined: 14 Jun 2006 Posts: 12
|
Posted: Thu Jun 15, 2006 10:04 am |
Still same...
Variable looks like (Players|playera|playerg|There).
This is how it looks now..
Code: |
#REGEX {^--------------------------------------------------\] Players \[-------------------------------------------------} {#var Who_Online {};#T+ {Player name storer}}
#REGEX{^-----------------------------> There are \a+ players in the Realms right now\. <----------------------------} {#T- {Player name storer}}
#REGEX "Player name storer" {\b(\a+)} {#AddItem Who_Online {%1}} "" {prompt} |
Ive tried changing the regex (did some reading on it) with no result. The only solution ive come up with is the one used here: http://forums.zuggsoft.com/phpbb/viewtopic.php?t=17203
however its more a way around 'my' problem. Would like to try get this to work.
Thanks
Best regards |
|
|
|
jolopez Novice
Joined: 31 May 2003 Posts: 49
|
Posted: Thu Jun 15, 2006 11:53 am |
i think you can do a who online that is in better way to handle ... line one by one who -t or who -l something like this .....
in this manner you can do a trigger per line and capture all line and capture what you want of the line |
|
|
|
Belial Beginner
Joined: 14 Jun 2006 Posts: 12
|
Posted: Thu Jun 15, 2006 12:08 pm |
Yes.. The mud got a command for that. Each player on a single line, however since it 'features' titles and surnames the playername could be anywhere on that line.. the who command without syntax is the only clean output.
Best regards |
|
|
|
Strakc Apprentice
Joined: 31 Jan 2006 Posts: 106 Location: Virginia Beach, Virginia
|
Posted: Thu Jun 15, 2006 12:24 pm |
Donno where I found this... but this captures names in a list like this.
Quote: |
Enemies of the Forest of Glomdoring:
Visaeris, Solis, Bandeon, Narsrim, Gero, Yukari, Erion, Rafael, Dhlon, Yuniko, ( HUGE GAP, to make to point without flooding it )
Noriaki, Nyla, Narice, Mirk, Eromhlak, Erageon, Lyco, Derian, Selwin, Keldoran,
Yurika, Rusta, Peeka, Mornen, Kharne, Umbrawn
Total: 180 |
Code: |
#CLASS {Utilities}
#ALIAS getcnames {
#if (%1 == done) {#t- "GetCnamesTriggers"} {
ScratchVar = %1
#var %1 ""
#t+ "GetCnamesTriggers"
%-2
}
}
#CLASS 0
#CLASS {Utilities|GetCnamesTriggers}
#TRIGGER "tGetCnames1" {^(%w), (*)$} {
#if (%left( @ScratchVar, 1)=l and %len( %trim( %1))<>0) {
#additem @ScratchVar %trim( %1)
#forall {%replace( %replace( "%2", ", ", "|"), ",", "")} {#if (%len( %trim( %i))<>0) {#additem @ScratchVar %i}}
}
}
#TRIGGER "tGetCnames2" {(%w)$Total: %d$} {
#if (%left( @ScratchVar, 1)=l and %len( %trim( %1))<>0) {#additem @ScratchVar %1}
getcnames done
}
#TRIGGER "tGetCnames3" {^, (%w), (*)$} {
#if (%left( @ScratchVar, 1)=l and %len( %trim( %1))<>0) {
#additem @ScratchVar %trim( %1)
#forall {%replace( %replace( "%2", ", ", "|"), ",", "")} {#if (%len( %trim( %i))<>0) {#additem @ScratchVar %i}}
}
}
#CLASS 0 |
puts them all in a list variable? donno if this will help at all but. |
|
|
|
jolopez Novice
Joined: 31 May 2003 Posts: 49
|
Posted: Thu Jun 15, 2006 2:40 pm |
belial from each line you can get the first word and add it to your list variable
i think the function is %word(var,1) more or less ... dont remember ... my .mud is in windows :D
(i can run it on linux too, but i dont have installed the requiered program in my laptop)
edited: use #additem list %1 or something to have in list variables
after that use #cw red {@list} and you will have red all online people |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Fri Jun 16, 2006 12:14 am |
Hmm. Remembered that trigger could fire multiple times per line. Oh, well this works too.
Code: |
(\a+)(?: (\a+)|)(?: (\a+)|)(?: (\a+)|)(?: (\a+)|)(?: (\a+)|)
#AddItem Who_Online {%1}
#AddItem Who_Online {%2}
#AddItem Who_Online {%3}
#AddItem Who_Online {%4}
#AddItem Who_Online {%5}
#AddItem Who_Online {%6} |
If i line can have more than 6 names, simply copy&paste and continue the list. This works even with one name in a line. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
Ceres Wanderer
Joined: 25 May 2006 Posts: 88
|
Posted: Fri Jun 16, 2006 1:53 am |
Try this (untested):
Code: |
#VARIABLE Who_Online {} {}
#REGEX {^-+\] Players} {#VARIABLE Who_Online {}
#T+ {Player name storer}}
#CLASS {Player name storer} {disable}
#VARIABLE Temp_Who_Online {} {}
#REGEX {^-+\> There} {#T- {Player name storer}}
#REGEX {(.*)} {#VARIABLE Temp_Who_Online {%1}
#VARIABLE Temp_Who_Online {%replace( %1, " ", "|")}
#FORALL @Temp_Who_Online {#ADDITEM Who_Online {i}}}
#CLASS 0 |
|
|
|
|
Belial Beginner
Joined: 14 Jun 2006 Posts: 12
|
Posted: Sat Jun 17, 2006 10:34 pm |
Finally!!
Thanks BlackSmith and Ceres, both your suggestions worked like a charm |
|
|
|
|
|