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
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Thu May 08, 2003 8:01 pm   

Retrieving and parsing values for ppls online
 
We all have friends and enemies, this is particularly obvious in MUDs... the "problem" can however escalate as your pool of "people to watch out for" keeps growing.

In my mud (moongate.net) there are a lot of clans and some of them are PK. I'd like a script that stores the clanmembers of PK clans in an array.

This is how it should work:
1. I store which clans are enemies (number 23, 31 etc)
2. The script does a "clan list 23; clan list 31" and STORES the clanmembers name in an array.
3. When I have the "notification" trigger on I will receive an echo if a clanmember turns up on a "where" or a "room scan" command. Alternatively I'll just have the script to color that person's name differently (bold red maybe ;).

Problem is that members join and quit clans regularly so everytime I run this "store clanmembers in arrays" I need first to "clear" the old array before I store new names in it. Preferably I'll have this script update itself automatically every time I logon to my Mud... then it is just left for me to turn ON or OFF the trigger with an alias (set_enemy_notification_ON).

Unfortunately this is my first time I try something more advanced and I really need every help I can get to set me on the right path...

Kindly,
Diablo
.keeper of Moongate
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri May 09, 2003 2:04 pm   
 
Lists are easier to work with than arrays.

Variables can be cleared by deleting them
#UNVAR enemies
or by setting them to a null value
#VAR enemies ""

You make a list by using the #ADDITEM command. This can be done from the command line or from a script.

Once you make a list, it can be used in the pattern of a trigger. Note the second set of {}.
#TR {{@enemies}} {#CW bold,red}

If you're just going to color the names a full-time trigger will probably work fine. For #ECHO, or other notification, you'll probably want to put the trigger in a subclass so that it can be easily disabled. Otherwise, you'd be spamming yourself whenever you fought an enemy.

LightBulb
Advanced Member
Reply with quote
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Sat May 24, 2003 4:46 pm   
 
Well, I have given this some serious thought but my limited experience with scripting forces me to come back with a follow-up question:

The text below is taken from my mud (the picture is somewhat distorted because in the mud the space between "No. Name Ranking" is wider to make everything turn up in straight columns).

To the "problem". I want a trigger to capture ALL the names (Enbringer, Lavan, Shizzle, etc) from the list and store them in my {@enemy} list. Specifically, how do I tell the trigger where to begin adding items and where to stop?

I guess, for collecting the names the rule should be something like after %d] collect next name %w. But specifically, how is it done?

Mud output on "clan list 23":

Member Roster for Clan #23, Dragon (Tribe):
No. Name Ranking
-----------------------------------------
[ 1] Enbringer Elder
[ 2] Lavan Aide
[ 3] Shizzle Chieftan
[ 4] Caillean Chieftan
[ 5] Reis Subordinate
[ 6] Caramon Subordinate
[ 7] Loman Chieftan
[ 8] Yankee Servant
[ 9] Valrow Servant
[ 10] Nakitta Subordinate
[ 11] Mararith Servant
[ 12] Tabasco Aide
[ 13] Kyratha Aide
[ 14] Deathbyfire Servant
[ 15] Starflare Servant
[ 16] Kirouac Aide
[ 17] Musaki Servant
[ 18] Vroz Servant
[ 19] Vycyn Servant
[ 20] Cepheron Servant
[ 21] Bostitch Aide
[ 22] Zalbag Servant
[ 23] Unbeliever Subordinate
[ 24] Krypt Servant

[*][SAFE]<2835hp 2951sp 1475st>
Reply with quote
neep
Beginner


Joined: 23 Apr 2003
Posts: 12
Location: USA

PostPosted: Sat May 24, 2003 5:43 pm   
 
to tell it when to start and stop, here's what I would do. Have a multi-state trigger (assuming your using a high enough version of zmud to have multi-state trigs) I don't know how to declare a multi-state trig by using text so I'll show you like it's two different trigs...

#TRI {^Member Roster for Clan ~#23, Dragon ~(Tribe~)~:} {#UNVAR enemies;#T+ enemy_capture}

second state:

#TRI {^~[~*~]~[SAFE~]~<(%n)hp (%n)sp (%n)st~>} {T- enemy_capture}

Whole new trigger (note that this trigger is in a subfolder named enemy_capture) Make sure on the subfolder that the box for "disable this folder when connecting to a mud" is checked, so that it is only enabled when you are trying to capture enemy names...

#TRI {^~[ (%n)~] &name_temp} {#ADDITEM enemies @name_temp} {enemy_capture}

Hope this helps
-Neep
Reply with quote
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Sat May 24, 2003 7:33 pm   
 
I tried the trigger and it worked partly, that is, it collects both name and rank:

Enbringer Elder
Lavan Aide


etc...

Another problem that turned up right now is the fact that players that are currently online get a star (*) just before their name, example:

[ 1] Enbringer Elder
[ 2] *Lavan Aide
[ 3] Shizzle Chieftan


In this case Lavan would be online.

So, what do I do to capture just the names (Enbringer, Lavan , Shizzle) and ignore any potential * just left of their names?

I realize this complicates things, somewhat



Kindly,
Mikael
Reply with quote
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Sat May 24, 2003 8:11 pm   
 
Well, after a bit more fiddling I have a working solution, following two triggers capture the NAME from the list:

PATTERN: ^~[(%s)(%n)~](%s)(%w)
VALUE: #ADDITEM pk_enemy_list %4

PATTERN: ^~[(%s)(%n)~](%s)~*(%w)
VALUE: #ADDITEM pk_enemy_list %4

The last trigger only captures names that preceede a star.

I'm sure there exist a more elegant solution and if you have one by your hand please feel free to mail me
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 24, 2003 9:36 pm   
 
What you've got is actually quite good. It can be reduced to a single trigger if you want.

PATTERN: ^~[%s%d~]%s(%x)
VALUE: #IF (%begins( %1, "*")) {#ADDI pk_enemy_list %right( %1, 1)} {#ADDITEM pk_enemy_list %1}

LightBulb
Advanced Member
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