|
Raikirah Newbie
Joined: 23 Jul 2006 Posts: 3
|
Posted: Sun Jul 23, 2006 12:22 pm
scripting help |
Alright, I already have a basic idea of what I'm going to need, I just don't have the final version yet. So, here goes.
I'm trying to make a way to query a list of names from the MUD I'm on, and have a trigger search those entries and, depending on if they are in a certain "clan", add them to a database. Then, whenever one of those names comes up (for example, in my immediate area), color flag that name so I know its a Hostile. I would rather not have to manually add these names to the database, but if it can't be helped, it can't be.
So, here's what I was thinking. I'll need an #ONINPUT trigger to match the "whoclan" command that I send to the MUD. Then, this trigger would need to capture every line it receives until it gets to the end of the list (signified with a line that tells the total number of entries.) As it captures these lines, it needs to check for a certain set of delimiters inside the string. If they match, then it would use %additem to add them to a database.
The second trigger would need to check this list every time I used the "scan" command.
So, anyone willing to help me out with a little actual code? I haven't used zMUD in forever, so my zScript coding is a bit (read: very) rusty.
Oh, and if you need actual mud input to match for the triggers, it is as follows:
whoc
[51 Pal] [ Knighthood ] Aenarion Colonel:Crown (Recruiter)
Total: 8.
This is an example of the whoclan return. It will usually have several names listed. The name is the first unbracketed item, and the delimiters needed are the second bracketed item.
scan
Looking around you see:
Scelel, right here.
a giant obsidian golem, nearby to the west.
the ancient wizard, nearby to the up.
This is a copy of the scan command, which searches my immediate area.
Any help would be appreciated. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Jul 23, 2006 4:59 pm |
You have exactly the right idea. Here's a little push to help you.
This article has an example very similar to what you want to do with the "whoclan" output in the "Resetting Triggers" section. However, instead of using a regular trigger as the first state of the multi-state trigger, you would use an oninput trigger. Something like this:
#ONINPUT WhoClanTrig {^whoclan$} {#VAR hostiles {};#TEMP {^Total: %d.$} {#STATE WhoClanTrig 0}}
#COND {^~[%d %w~] ~[ (%w) ~] (%w) *} {#IF (%1 = "Knighthood") {#ADDITEM hostiles {%2}} {LoopLines|Param=99}
First notice that the @hostiles variable will be a stringlist. Based on what you described, a stringlist variable should do the job. Next, notice the #TEMP trigger. This trigger will match the end of the "whoclan" output and reset the state of the multi-state trigger back to the first one (waiting until you enter "whoclan" in the command line). Once this first oninput state is finished, the multi-state trigger goes to the second state, which is of type LoopLines. What this does is that each time a line is received from the MUD that matches the pattern of this state, it will continue executing its commands. This will be done until 99 lines have been received. However, the #TEMP trigger that was created earlier will make the multi-state trigger get out of this state once it find the line that tells you the "whoclan" output has been finished, so this state will not actually match 99 lines. What this second state does is to check if that particular person belongs to the clan "Knighthood" and then add the person of the stringlist if this is true. Note that if the "whoclan" output may return more than 99 lines, then you would need to increase the Parameter value for the second state.
For highlighting the names of hostiles, you can use a simple trigger if you don't mind the names being highlighted always, not just when using scan. Something like this would do:
#TRIGGER {{@hostiles}} {#CW red}
This trigger would match any of the names in the @hostiles stringlist and color them red. |
|
_________________ Kjata
Last edited by Kjata on Mon Jul 24, 2006 2:04 am; edited 1 time in total |
|
|
|
Raikirah Newbie
Joined: 23 Jul 2006 Posts: 3
|
Posted: Sun Jul 23, 2006 7:49 pm |
*feels dumb* I remembered all of that as I read it. Wow, its been a while since I did any coding. Thanks alot Kjata. Now all I need to do is change this so that it works with CMUD... which, by the way, does NOT like #ONINPUT in the command line. *sigh* I can do the rest myself.
|
|
|
|
|
|
|
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
|
|