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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
gedron
Beginner


Joined: 01 Feb 2003
Posts: 15

PostPosted: Wed Feb 05, 2003 3:01 am   

Dynamic Speed Menu
 
I wanted to have a way to use the speed menu to perform actions on whatever mobs/items were in the room I was in. This is what I came up with, with some starting help from a few others. After alot of experimentation and hair pulling, I decided to use the simple expedient of deleting and then recreating the menu items as I needed them. I've included extensive descriptions for the novices out there, in the hopes that someone else will find it useful. Skip to the bottom for a summary (I get into alot of detail here).

#MENU "Attack" {} "" "Attack_Targets"

This line creates a top level speed menu item called "Attack" that looks to the "Attack_Targets" class folder for submenu items. We will later have a trigger make submenu items from some mud output.

In the line to come I will describe the creation of an alias. I do not actually use this method myself, instead I assigned a macro key to do the functions that the alias provides. So in practice instead of typing in something to get my speed menu prepared all I have to do is hit a certain key. I used the alias in this example because, frankly, I don't really know how to assign macro keys from the zMUD prompt.


#ALIAS x {#DELCLASS Attack_Targets;info here}


Assigns the alias "x" that will delete the class folder "Attack_Targets" and anything in it, clearing out the submenu for future use. It then sends "info here" to the mud which in turn (on my mud anyway) sends back a list of what is in the room formatted something like this:


"sigil19878" a monolith sigil.
"Shinobu6992" Sister Shinobu.
"shrine544" a shrine of Iosyne.
"rat36067" an old rat.


#TRIGGER {^~"%w(%d)~"%s(*).} {#CLASS Attack_Targets {menu};#MENU "%2 - %1" {kill %1};#CLASS 0;#GAG}


#TRIGGER creates a trigger that will fire when a line formatted like the sample data comes from my mud. To break down the criteria (the stuff inside the first set of {brackets}), the ^ symbol (shift-6) specifies beginning on a new line. The ~ is there because I want to use a " as part of the matching criteria, and without the ~ preceding it the trigger would assume we were trying to do something else with the quote rather than actually looking for one. The %w is a wildcard meaning any combination of letters.

The (%d) part is another wildcard, this time referencing any numerical value. However note that the parentheses surrounding %d identify that the value within it is an output value, we will be using this later. Then we have ~" which is more pattern matching that fits my criteria. Then %s which is a wildcard that matches any number of spaces. Another wildcard (*) as the second output value, because of the surrounding ()'s, followed by a period because all of my mud's lists have them. That’s a pretty specific set of criteria that has so far proven unique on the mud I use so I don't feel the need to use classes for turning the trigger on and off to avoid erroneous data.

The trigger criteria will parse the line out so that the numerical value between the quotation marks, which I can use to address actions to a specific creature/item in the mud, as %1. The text description following will be %2 which I use as a label for the submenus to choose which one I want to perform the action on. So for example after triggering on the first line of the example above, %1 = 19878 and %2 = a monolith sigil.

The stuff between the second set of {brackets} is the part that is executed when it fires off. The first thing the trigger actually DOES is change the current class folder to Attack_Targets, so that any menus, triggers, what have you, that are made will be created in that class folder. Then the trigger uses the output values of %1 and %2 (grabbed earlier in the criteria part of the trigger) to create the name displayed in the speed menu item "%2 - %1" and to define the command sent to the mud if this submenu item is selected, in the case of the first example, "Kill 19878" is what will be sent to the mud if the menu item is selected. The next thing the trigger does is return the current class to the default of 0 so when we are done things will be as they should be.

Finally, the #GAG command at the end prevents the output from the mud from being displayed on the screen. I find this a visual improvement, but its a personal choice really.



So in summary, the lines below will create a dynamic list of what’s in the room that will be updated every time you type in the alias "x", or hit a designated key (assuming you set up a macro for it like I did), of everything in the room on your speed menu (right-click). You should easily be able to adapt this to any number of different uses, like changing the attack menu to a get menu, or by changing the criteria, of making any listed info from your mud available for actions by the speed-menu. If you wanted it to be even more up-to-date (the way I have it set) without always having to manually update the list, you could add the alias to your movement keys. That way every time you entered a room you'd also get the listing updated.


#MENU "Attack" {} "" "Attack_Targets"
#ALIAS x {#DELCLASS Attack_Targets;info here}
#TRIGGER {^~"%w(%d)~"%s(*).} {#CLASS Attack_Targets {menu};#MENU "%2 - %1" {kill %1};#CLASS 0;#GAG}




Gedron
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Feb 05, 2003 4:43 am   
 
Nicely done. A simple script and a good explanation.

This should work as is with Achaea, Aetolia, Avalon, and any similar MUDs.

LightBulb
Advanced Member
Reply with quote
Amylon
Novice


Joined: 31 Jan 2003
Posts: 49
Location: Australia

PostPosted: Wed Feb 05, 2003 8:05 am   
 
Agreed! As a player of Achaea this script has made life alot easier. Also I would like to congratulate you on perhaps the best script post I have seen, very helpful and informative, keep up the good work!

--------------------
#trigger {(*) tells you, '} {tell %1 NO}
--------------------
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Wed Feb 05, 2003 11:36 pm   
 
Very nice idea. Just wanted to comment on it ever so slightly.
For Achaeans out there, you will need to remove the period " . " from the trigger pattern, as otherwise it wont fire, cos info here doesnt have a period in it... at least, not all the time.

Also, I noticed that in the menu itself, it shows something like:
%trim({ a guard} 2347
Rather than
a guard 2347

It comes up with the right thing once you select it though, of course. But...if you want it to look a bit better in the menu, try...

#TR {^~"%w(%d)~"%s(*)} {#CLASS Attack_Targets {menu};#MENU "%2 - %1" {kill %1};#CLASS 0;#GAG}

The %s negates the need to use %trim on it, which means it doesnt show up in the speed menu.

Anyhoo...just like to say (again) well done on a brilliant idea. Particularly useful when you're bashing in a group and wish to take out a larger group of teaming mobs by having each person in the group target a different one. Which actually gives me another idea for it.

Say I was with a group, attacking a party of guards. We want to each attack a specific one, and after its dead, just attack "guard" in general. If the trigger pattern was changed slightly...

#TR {^~"(%a)~"%s(*)}
%a being a wildcard which matches any combination of letters & numbers. And the command in the speedmenu being something along the lines of "target=%1" instead of "kill %1", then this alias would change the value of that variable from

guard12334
to
guard

#ALIAS xx {#SHOW "+++" @target "+++" Generalising @target!!!}
#TR {+++ (%w)%d +++} {target=%1}

There's -so- much that can be done with this script of yours. Awesome idea.

Caled
Reply with quote
gedron
Beginner


Joined: 01 Feb 2003
Posts: 15

PostPosted: Thu Feb 06, 2003 12:58 am   
 
Glad you folks liked it.

About the Trim issue, I was not able to recreate the garbage you were getting in your menu, Caled. Perhaps you were missing a ) or something?

Anyway, I like your %s approach better. Its cleaner, simpler (always better), and I think novices would understand it better. I liked it so much I edited the original post to reflect the improvement, and while I was at it I got carried away with playing with colors

Happy Hunting,
Gedron
Reply with quote
Kendrick
Beginner


Joined: 28 Aug 2003
Posts: 25
Location: USA

PostPosted: Thu Aug 28, 2003 6:27 am   
 
Hey yeah. That's a nice newbie-friendly script. I'm liking it a lot. I'll add my Achaean version of it:

#TRIGGER {^~"%w(%d)~"%s(*)} {#CLASS Attack_Targets {menu};#MENU "%2 - %1" {ST en %1};#CLASS 0;#GAG}

The ST is for Settarget. And en, is the name I give the target, which can be anything you would prefer to use.

So basically, I don't take any real action from the menu, but instead, choose to do whatever, and use ingame aliases like PE for punch en. Or pick up en etc. I'll probably mess around with it more later, because this is a good script u can modify for more uses it looks like.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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