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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Sun Jan 26, 2003 2:10 pm   

Script help
 
Im trying to make a script that captures
names in a who list, then colors them based
on thier race when they walk into a room.
Like all humans name would be brown when
they walk into a room.

The ouput goes as followed....

[ Human ] PK Zity the Guardian of Knowledge
[ Human ] Rashanktir Filibreath the General of Legion
[ Elf ] Nolan hj the Scout
[ Human ] Shichiirobei the Master of Dragons
[ Human ] Prashidah Shalon the Disciple of the Unexplained
[ Drow ] Cibolo Poliplo the Wrath of the Blasphemers
[ Fell ] Zanxip Xtallip the Berserker
[ Avian ] PK (WANTED) (TRAITOR) Nytanthan Adumbro the Master of Taste
[ Fell ] Zenzim Xtallip the Knight
[ Duerg ] PK [Justice] Niszacombas Muhaad the Adept of Faith
[ Fire ] Dringa the Champion

There are angle backets around PK but it dosent
show up here. Ayways the hard part is that
the name isnt always just to the right of
the race. sometimes PK is there, or (WANTED)
and stuff like that. However things to the
left of the name are always in angle brackets,
parenthises, or normal brackets. They get
in the way and make it hard to add the person
to the list.

Any examples, or help would be greatly appreciated. :)

-Sin
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jan 26, 2003 3:46 pm   
 
Catch everything after the race, convert it to a string list, and use a loop to remove teh items that start with <, (, or [, then convert it back to a string and store the name and race in a record variable. Example:
#VAR people ""
#TRIGGER {~[ (%w) ~] (*)} {#VAR name {%replace("%2", " ", "|")};#WHILE (%item(@name, 1) =~ "^{[|(|<}") {#DELNITEM name 1};#VAR name {%replace(@name, "|", " ")};#ADDKEY people {@name} {%1}}

If you do not want the part that comes after "the", it can be dropped too. The you would have another trigger that fires on any of the record variable's key and colors it according to it's value. Example:
#TRIGGER {({@people})} {#IF (%db(@people, "%1") = "human") {#CW brown};#IF (%db(@people, "%1") = "elf") {#CW red};etc.}

Kjata
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Sun Jan 26, 2003 5:32 pm   
 
/bow kjata

i changed the pattern match to allow any number
of white space in between cause the space varys
and it wasnt picking up most of them.
Reason i add that, for some reason (TRAITOR)
and (WANTED) still show in the list and i dont
have the slightest idea why. It dose however remove
the <PK and [JUSTICE] tags

#VAR people ""
#TRIGGER {~[%s(%w)%s~] (*)} {#VAR name {%replace("%2", " ", "|")};#WHILE (%item(@name, 1) =~ "^{[|(|<}") {#DELNITEM name 1};#VAR name {%replace(@name, "|", " ")};#ADDKEY people {@name} {%1}}
#TRIGGER {({@people})} {#IF (%db(@people, "%1") = "human") {#CW brown};#IF (%db(@people, "%1") = "elf") {#CW red};etc.}

Also could you show me how to kick everything
after "the" as well? or How to trash everything
after the first word after the trigger removes
all the unwanted (,[,< words. seems safer.

This is mainly for stuff like....
Sinrae walks in.
Sinrae walks west.

So i dont have any use for anything after "the"
so i know what race they are before they
beat me into a pulp while i check.

You guys dont get enough praise, thanks
a ton.

-Sin
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jan 26, 2003 6:37 pm   
 
To correct the thing with the parenthesis try changing the part of the script that has:
"^{[|(|<}"

to:
"^{[|~(|<}"

To only use the first word of the name change the command:
#VAR name {%replace(@name, "|", " ")}

to:
#VAR name {%item(@name, 1)}

Kjata
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Mon Jan 27, 2003 11:19 am   
 
Thank you kjata

-Sin
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Tue Jan 28, 2003 4:40 pm   
 
Ran into a problem.....
Thought it was working right but dosent look
like it is (wanted) and (Traitor) still dont
work with the "^{[|~(|<}" addition. I put
an #echo name right before the while loop
and an #echo @name %1 after the var removes
everything but the first word to see what
was going on and this is the output....

[ Human ] Phaleg Dragonsbane the Divine Healer
Phaleg|Dragonsbane|the|Divine|Healer
Phaleg Human
[ Drow ] Somel the Thaumaturgist
Somel|the|Thaumaturgist
Somel Drow
[ Elf ] <PK> Lang the Vicar
<PK>|Lang|the|Vicar
Lang Elf
[ Elf ] Narain the Templar Lieutenant
Narain|the|Templar|Lieutenant
Narain Elf
[ Avian ] (TRAITOR) Sinivetikas the Shapeshifter
(TRAITOR)|Sinivetikas|the|Shapeshifter
[ Slith ] Iiyardur the Ranger of the Second Circle
Iiyardur|the|Ranger|of|the|Second|Circle
Iiyardur Slith
[ Fell ] Qucrax the Berserker Lord
Qucrax|the|Berserker|Lord
Qucrax Fell
[ Dwarf ] Wothyrd the Paladin Knight
Wothyrd|the|Paladin|Knight
Wothyrd Dwarf
[ Slith ] Hssthok the Overlord
Hssthok|the|Overlord
Hssthok Slith
[ Stone ] Tuman Daranthai the Baron of Hurricanes
Tuman|Daranthai|the|Baron|of|Hurricanes
Tuman Stone
[ Duerg ] Unzchabiewch the Cut-Throat
Unzchabiewch|the|Cut-Throat
Unzchabiewch Duerg
[ Elf ] Elywyn Celithrandil the Warder Captain
Elywyn|Celithrandil|the|Warder|Captain
Elywyn Elf
Players matched: 16
There are 19 characters on, the most on since startup was 53.

<136hp 351m 252mv> Elywyn Avian

I noticed that Going into the while loop everything
is fine, but the (TRAITOR) one dosent come
through the while loop. Then his race is
assigned to the last person on the list.
if there are two (TRAITOR)'s both thier
races get assigned to the last person on
the list and so on....Making the last person
the wrong race. The ( isnt being matched.
i notice it dosen show up in the list sometimes
either. Everything else works fine i just
cant get the loop to match (TRAITOR) or (WANTED)
=(
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Jan 28, 2003 9:11 pm   
 
Oops, sorry. I forgot that parenthesis have special meaning inside a stringlist. Try changin the trigger to this:
#TRIGGER {~[ (%w) ~] (*)} {#VAR name {%replace(%replace("%2", "(", "<"), ")", ">")};#VAR name {%replace(@name, " ", "|")};#WHILE (%item(@name, 1) =~ "^{[|<}") {#DELNITEM name 1};#VAR name {%replace(@name, "|", " ")};#ADDKEY people {@name} {%1}}

The parts that have been changed/added are in italics.

Kjata
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Tue Jan 28, 2003 9:13 pm   
 
I figured it out, the mud spits it out too
fast for the script to keep up, things just
end up flying everywhere. any way to make
it fork itself or something similar?
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Jan 28, 2003 9:18 pm   
 
Try the solution in the reply above. I'm guessing that the problem is due to this and not the MUD being too fast.

Kjata
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Tue Jan 28, 2003 9:53 pm   
 
Ok, i changed the scipt. it works when
i do them single, but when i do a who
all together it goes nuts and can't keep
up.

whois nis
[ Duerg ] (PK) Niszacombas Muhaad the Adept of Faith
Niszacombas Duerg <(====echo works great
Players matched: 1

<464hp 321m 342mv> <9am city> whois den
[ Half ] (PK) Dentasech Delean the Sword of the Forest
Dentasech Half <(====echo, good
Players matched: 1

<464hp 321m 342mv> <9am city> whois iiyard
[ Slith ] (PK) Iiyardur the Warder General
Iiyardur Slith <(====echo, nice
Players matched: 1

<464hp 321m 342mv> <9am city> whois bannal
[ Drow ] (PK) Bannal the Mokuroku
Bannal Drow <(====echo, good again
Players matched: 1

That goes well but...........
.....Now all at once..........

<464hp 321m 342mv> <9am city> who pk
[ Duerg ] (PK) Niszacombas Muhaad the Adept of Faith
Niszacombas Duerg <(=== echo, good so far
[ Half ] (PK) Dentasech Delean the Sword of the Forest <(===missed, didnt echo
[ Drow ] (PK) Bannal the Mokuroku
Bannal Drow <(====echo, worked ok
[ Slith ] (PK) Iiyardur the Warder General
Players matched: 5
There are 34 characters on, the most on since startup was 53.

<464hp 321m 342mv> <9am city> Iiyardur Slith <(====echo but very late
Iiyardur Half <(====echo but very late and not even the right race.

By themselves it works on every one of them.
But when the mud spits them out all at once
it goes nuts =/. I tested it over and over
with the same results every time. Your addition did
however fix the (wanted) problem =P

Thanks for all the help Kjata

-Sin
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jan 29, 2003 12:36 am   
 
Your problem is caused by the fashion in which whiles process. I changed the script to on that requires less processing and eliminated the while.

#CLASS {wholister}
#ALIAS clearname {#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)};#IF (%ascii( @name)<65) {name=%remove( %concat( %word( @name, 1), " "), @name)}}
#VAR name {Iiyardur the Warder General}
#VAR people {}
#TRIGGER {^~[ (%w) ~] (*)} {#VAR name {%replace( %replace( %replace( "%2", "[", "'"), "<", "'"), "(", "'")};clearname;#ADDKEY people {%word( @name, 1)} {%1}}
#CLASS 0

The clearname alias will strip 10 tags from a name. If that is overkill remove a few lines, if that isn't enough duplicate the lines somemore.
Reply with quote
Sinrae
Beginner


Joined: 01 Jan 2002
Posts: 10
Location: USA

PostPosted: Wed Jan 29, 2003 12:09 pm   
 
Wonderfull!
Works great!

Thanks so much guys.

-Sin
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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