|
itsr0y Beginner
Joined: 20 Jan 2002 Posts: 25
|
Posted: Wed Jan 23, 2002 9:14 pm
Dynamic SpeedMenus |
Is there anyway to dynamically create a speed menu? Right now, the name and command for a speedmenu are taken verbatim from the script, and I cannot get zMUD to parse any functions. For example:
title = "SM1"
aliasname = "sleep;stand"
#MENU @title {%alias( @aliasname)}
title = "WRONG"
aliasname = "WRONG VALUE"
Will create a menu item with name @title and value %alias( @aliasname). Then it will parse the @title and %alias( @aliasname) when I try to use the menu, thus having the wrong values (I want them to be constant anyway).
Is there any way to get zMUD to parse the functions and variables so I can have a menu created (for the above example) with name "SM1" and value "sleep;stand"?
Thanks |
|
|
|
undergod Wanderer
Joined: 27 Jun 2001 Posts: 82
|
Posted: Wed Jan 23, 2002 9:25 pm |
The easiest way would be to just use:
#MENU SM1 {sleep;stand}
If you are using a variable, the menu will update itself whenever the variable changes. Hence the name, variable. If you want to use a constant, don't change the variable or just use the actual phrase. |
|
|
|
itsr0y Beginner
Joined: 20 Jan 2002 Posts: 25
|
Posted: Wed Jan 23, 2002 10:06 pm |
No, I just want that for that example. What I want to do is read some lines (list of monsters) from the MUD and create a bunch of menu items from that list. I don't want to have to store all the names in separate variables - I want the name of each menu to be a string that I set when the trigger fires. The reason I didn't put the trigger is its rather complicated, and I just need to know if what I'm asking is possible. Thanks for your reply though (sorry I wan't too clear.)
|
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Jan 23, 2002 11:11 pm |
It seems that you have variable expansion in the command line enabled. Click on the Prefs button and go to Script Parser. Make sure Expand Vars is unchecked.
If you do not want to disable variable expansion in the command line, then create the menu item using the settings editor.
Also, one thing to notice is that %alias returns the contents of the alias whose name is the one you supply to the function. It does not execute commands. So, if you set @aliasname to "sleep;stand" and then do:
%alias(@aliasname)
it will try to find an alias named sleep;stand and expand it.
What you should do, instead, is to use this as the commands of the menu item:
#EXEC @commands
The #EXEC command executes the arguments you pass to it. If you then set @commands to "sleep;stand", when you click on the menu item, it will send sleep and stand to the MUD.
Kjata |
|
|
|
itsr0y Beginner
Joined: 20 Jan 2002 Posts: 25
|
Posted: Thu Jan 24, 2002 12:10 am |
Hmm, I guess I should just post my code and not simplify it. I'm sorry for so much confusion.
#TRIGGER "CpListTrig" {You still have to kill} {
#VAR cparea "" "" QLists
#FORALL @CpList {#UNMENU %1 CampaignClass;#DELITEM CpList %1}
#TEMP {^You have} {#STATE CpListTrig 0}
cparea = %right( %line, %pos( "(", %line))
cparea = %left( @area, %pos( ")", @cparea)-1)
#MENU {%right( %line, 25)} {
%alias( %concat( "run_", %remove( "The ", @cparea)))
} CampaignClass
#ADDITEM CpList {%right( %line, 25)}
} "QLists"
#COND "CpListTrig" {} {
cparea = %right( %line, %pos( "(", %line))
cparea = %left( @cparea, %pos( ")", @area)-1)
#MENU {%right( %line, 25)} {
%alias( %concat( "run_", %remove( "The ", @cparea)))
} CampaignClass
#ADDITEM CpList {%right( %line, 25)}
} {"looplines"|"param=99"}
Now, I didn't cut anything out, and so that's all my code. Please note, I didn't use the commandline, I used the settings editor.
The problem is that it sets the name of the menu to be %right( %line, 25) rather than parsing it right then. Any ideas? |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Jan 24, 2002 12:25 am |
This looks suspiciously like a post a little while ago. Only difference was the guy wanted to create ALARMs based on data in a file. Anyhow you should only have to change one line (I am sure you can find the original):
#EXEC %expand(#MENU {%right( %line, 25)} { %alias( %concat( "run_", %remove( "The ", @cparea)))} CampaignClass) |
|
|
|
itsr0y Beginner
Joined: 20 Jan 2002 Posts: 25
|
Posted: Thu Jan 24, 2002 5:21 am |
thanks! that does the trick! The only thing is the window says there's an error in the script, but it runs fine. I guess its just a bug. Thanks again!
|
|
|
|
|
|
|
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
|
|