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
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Jan 10, 2005 10:47 am   

Dynamic Speedmenus
 
Hi there,

I'm trying to create a speedmenu that only appears when I click on certain words.

The mud I play has ships that will display as follows:

clipper: 123456
clipper: 654321
caravel: 456789
man o war: 987654

What I'd like is to be able to right-click on the id number and have a quickmenu appear letting me board the specific ship.

Currently I have:
#MENU {boardShip} {board %selword} ""

This works fine, but the speedmenu exists for everything I right click on. What I'd like is a menu that checks what comes before %selword, and if it's either clipper, caravel or man o war then it offers me the boardship speedmenu, if it's anything else then it doesn't.

So effectively it'll take the form
(*): (%d)

and when I right-click on %d

if %1 = {clipper|man o war|caravel}
then boardship speedmenu visible (which would then boardship %2 when chosen)
else boardship menu hidden


The theory is that if I get this working properly then I'll do similar things for players, mobs, industries etc.

Any help much appreciated.

Guinn
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Jan 10, 2005 11:09 am   
 
You might be able to get something out of %selline. However the menu will always be displayed. I will see if I can come up with something later today when I get home.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Mon Jan 10, 2005 11:25 am   
 
You have it right you just need to fine tune it a bit.

First have a TRIGGER to start turn off and on the class.

Code:

#var ships {clipper|man o war|caravel}
#trig {^@ships %d$} {#t+ boardShip}


Then ofcoars is the second half
Code:

#menu {boardship} {board %selword}


Now I actually like using #MXP tags for this type of thing myself

Code:

#trigger {^{@ships} (%d)$} {#mxp <send "board %1">board</send>}
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Tue Jan 11, 2005 12:07 am   
 
Thanks both for the replies.

Megamog,

just to go through the code you posted

Quote:
#var ships {clipper|man o war|caravel}
#trig {^@ships %d$} {#t+ boardShip}

When zmud sees a ship, enable the boardship trigger

Quote:
#menu {boardship} {board %selword}

The actual speedmenu (as enabled by the previous part)

Quote:
#trigger {^{@ships} (%d)$} {#mxp <send "board %1">board</send>}

MXP (will ignore for the purposes of the question)



This would work, but the problem is that I rarely will want to board a ship. It may be when I check what's in the room I'll get a list that could include

Monster: 100001
Beastie: 100002
Clipper: 100003
Silver Ring: 100004
Merchant: 100005
Man o War: 100006

If I right clicked on 100001 or 100002 then I'd want to see possible attacks
If I right clicked on 100003 or 100006 then I'd want to see the ships menu
If I right clicked on 100004 I would want to see an option to pick up the ring
If I right clicked on 100005 I would want to see the option to list goods from that merchant.

Basically, the ids may be all mixed up in one list, so to enable a menu once I see the text isn't enough - it's got to enable only when I rightclick on the id associated with it.

So morelike

Code:
#if (leftmostwords(%selline)) = {@thingsToAttack} {attack %selword)
#if (leftmostwords(%selline)) = {@ships} {board %selword)
#if (leftmostwords(%selline)) = {@merchants} {list goods)
#if (leftmostwords(%selline)) = {@jewellery} {get %selword}


That's a simplified version of what might appear, but should indicate the sort of thing I'm after.

As a sidenote, it's easy to make a menu with the caption %selword that does #say %selline, so seems more that the problem is to do with enabling/disabling/creating menus based on the %selword value, rather than actually displaying %selword contents...

Thanks again for the help. This feels to me like a slightly odd one to solve ;)
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Tue Jan 11, 2005 2:51 pm   
 
The #MXP I wrote was to be used seperste frm the other code.
The other code was just an example and would occoarse need to be shut off when not in use.

What you need is a whol script to get everything in order.

#menu is ok, and you could simplify it to give you a list of thing to do with the number.
However I think #mxp is still the way to go
It just gives you way more versitality and your not left with figuring out how to turn on and off the folders at the oproprite times, as #mxp works with #trigger it just leaves behind it's results.

But like you said it would take a little bit of work.
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Tue Jan 11, 2005 9:05 pm   
 
Megamog,

Thanks again. I not sure if I've quite conveyed what I'm after. The MXP looks useful, but not sure if it gives the flexibility I'm after, the problem being that the trigger will always fire and underline words (which would look messy if used in bulk) and each MXP tag gives only one behaviour.
I agree MXP has many uses, but this time it's not something I want to go for.

Using triggers to open/close the speedmenu classes would be a bit messy too, as if there were ships, monsters, merchants in the same room then it'd open all 3 classes when I'd only ever click on one. Also it'd be near impossible to close them at the right time.



Anyways, after a bit of testing it seems that the problem boils down to whether I can use predefined variables (i.e. %selline and %selword) in expression triggers. The reason being that I only want my speedmenus to react to the word or line being clicked on rather than being controlled by the mud output.

What I think I'm after is (excuse the probably dodgy code, long day at work and don't have zmud at hand to check the syntax):

Code:
#trigger (%selword) {
#if (%selword = {@ships}) {class (shipsMenu) 1}
#if (%selword = {@mobs}) {class (mobsMenu) 1}
#if (%selword = {@merchants}) {class (merchantsMenu) 1}
}


Don't worry about what's in @merchants and merchantsMenu, I can sort those out easily enough, but it's the expression trigger that doesn't appear to work.

The most simple example I tried was to try and set an expression trigger saying that
#if (%selword = Hello) {#beep}

But then when I right-clicked on the word Hello it didn't beep...

So I'm rambling a bit, but basically I'm wondering if it's actually possible to do what I'd like, or if predefined variables are more limited than user defined ones.

More thanks ;)

Guinn
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jan 12, 2005 5:51 am   
 
Quote:

each MXP tag gives only one behaviour


And each ZMud command/function/etc gives only one behavior. The MXP tag you are looking for is SEND.../SEND, and aside from the many underlined words you don't want to have it does exactly what you are asking for (that is, an object-specific right click menu of unlimited choices).
_________________
EDIT: I didn't like my old signature
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Jan 12, 2005 8:16 am   
 
If you will put the coices you want for the items we talked about I could give you a better idea.

ship = bord
mob = kill bash loot stab (even aliases for say: get sword bag;kill)
merchant = list buy sell drop etc...........

Like I said #mxp really does not have to many limits.
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jan 12, 2005 8:58 am   
 
a few off the top of my head

{@ships}: (%d)
would probably only require 'board %1'

{@primaryindustry}: (%d)
options from
%1 stock
%1 maintenance
%1 accesslist

{@secondaryindustry}: (%d)
options from
%1 stock
%1 maintenance
%1 accesslist
%1 producelist

{@summonedundead}
options from
checkhealth %1
attack %1

{@playersonline}
examine %1
attackplayer - this would then lead to a list of available skills, the list varying by which character is online, and might have a different syntax.


I'm not sure how to get MXP to throw up a right-click menu. Having it to send one command when I clicked on a word was easy enough, but showing the list of commands I couldn't do.

Also, if MXP is the way to go, any way to specify not to underline words, as probably 90% of the time I'd not want to click on anything, so wouldn't want underlines everywhere as I'm just wandering about normally.


Thanks
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Jan 12, 2005 2:55 pm   
 
check the section in the help menu on "Using MXP"
they have an example that fits what you want, it goes something like this:

Code:

#MXP This is a <send "hello|command1|command2" "help me|First command|Second command">test</send>


Quote:

will create a hyperlink called "test". If you move the mouse over it, the "help me" text will be displayed. If you left-click on the hyperlink, the command "hello" is sent to the MUD. However, if you right-click on the hyperlink, you will get a popup menu with 3 commands listed. The first item will say "help me" and will send "hello" to the MUD when you select it. This is the same as left-clicking on the hyperlink. The second item in the menu will say "First command" and will send "command1" to the MUD when you select it. The third item in the menu will say "Second command" and will send "command2" to the MUD when you select it.


this is what I was thinking of for you, I will get back to you later with something more spicific.
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jan 12, 2005 5:05 pm   
 
Got the MXP menus working, thanks. Only problem is the menus seem to be one level deep at most. With attacks and industry maintenance there may be situations where I'd need a few levels deep as there could be 20-30 possible commands to use over a few levels.

Sorry to be awkward ;)

Guinn
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Jan 13, 2005 12:23 am   
 
If you just want status info without clicking, you might be able to shoehorn what you want to see into the SEND tag's HINT property. That appears to be equivalent to the Tooltip property found on Buttons, and I don't see any reason short of different parsing rules for it not to work. You just wouldn't be able to keep it all that dynamic because once it's on the screen you can't reparse it to update the tooltip.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 13, 2005 9:50 am   
 
I did this rather quickly with only minimal testing. You should be able to figure out how to add more menus and populate the needed lists.

#MENU {%if(%match(%selline,"(*): (%d)",SelName,SelNumber),%exec("#T+ SubMenus;EnableSubMenus"),%exec("#T- SubMenus;Unavailable"))} {} "" {SubMenus}
#CLASS SubMenus {menu}
#MENU {board} {board @SelNumber}
#MENU {stock} {stock @SelNumber}
#MENU {maintenance} {maintenance @SelNumber}
#MENU {accesslist} {accesslist @SelNumber}
#MENU {producelist} {producelist @SelNumber}
#CLASS 0
#VAR MenuNames {board|stock|maintenance|accesslist|producelist}
#ALIAS EnableSubMenus {#FORALL @MenuNames {#T- %i menu};#IF (%ismember(@SelName,@Ships)) {#T+ board menu;Board} {#IF (%ismember(@SelName,@PrimaryIndustry)) {#T+ stock menu;#T+ maintenance menu;#T+ accesslist menu;Industry} {#IF (%ismember(@SelName,@SecondaryIndustry)) {#T+ stock menu;#T+ maintenance menu;#T+ accesslist menu;#T+ producelist menu;SIndustry} {Unknown!}}}}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Jan 13, 2005 2:01 pm   
 
Vijilante,

Perfect, that's exactly what I'm after. I put in the code and it worked right off the bat with the basic commands you'd put in. I'll be able to populate the rest from that.

Out of curiosity, I'd tried unsucessfully to have an expression trigger on %selword to enable/disable the speedmenus, but it never seemed to work properly.
Any idea why the matching text had to be put into a #menu command, rather than the expression trigger based on %selword?

Anyways, I take my hat off to you ;)

And thanks to Matt and Megamog too, the MXP stuff looks well worth a play with in future.


Guinn
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 13, 2005 11:11 pm   
 
Expression triggers are checked on update of a variable. %selword and %selline are not actually variables and so do not cause the trigger to test or fire.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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