|
Voltz-dk Beginner
Joined: 28 Nov 2007 Posts: 15
|
Posted: Sat Dec 08, 2007 10:00 pm
[2.16] Problem with aliases across windows |
I don't know if I'm trying to do things too much ZMud way, but I have an issue.
I have a module with the common stuff, including 2 aliases
o3 {:G3:#EXEC %-1}
kt {kill @target}
Then windows for specific char stuff, in which I want to override kt for G3
kt {assault @target}
Now if I type kt inside G3, it assaults.
If I type "o3 kt" it kills, wheter this is done from G3 or another window.
But if I type ":G3:#EXEC kt" it assaults, again from any window.
If I type "o3 #EXEC kt", it actually does assault but it's a bit clumsy and worse it's accompanied by a stack exception.
I at least assume the stack exception to be a bug, but I'm puzzled why ":G3:#EXEC kt" and "o3 kt" gives different results. Anyone? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Dec 09, 2007 2:25 am |
Presumably it's because the current class isn't being changed from the module (which is the current class when the alias is run) to the window by the :window:command syntax. I can see an argument for it being either way, so I doubt that's going to change.
What you should do is only have one copy of each alias visible to each window. If you need to use different commands in the same alias for some characters, don't put it in the shared module at all, have a copy for each window. |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Sun Dec 09, 2007 3:28 pm |
I can see how being able to override default shared aliases can be useful though. I think the reason why ":G3:#EXEC kt" and "o3 kt" give different results is because when you use #EXEC, it's evaluated immediately, and at that point the context for the first command is your command line. When it is executed from within o3, the context is the shared module. I presume that if you put a copy of o3 into your window, it would work as you wanted. Someone may know of another solution.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Dec 11, 2007 6:16 pm |
Try changing your o3 alias to this:
Code: |
o3 {#EXEC {:G3:%-1}} |
and see if that helps. That will execute the code in the G3 window at runtime instead of within the current context.
I'll try to see if I can change :G3: to also change the execution context. |
|
|
|
Voltz-dk Beginner
Joined: 28 Nov 2007 Posts: 15
|
Posted: Wed Dec 12, 2007 12:16 am |
Alias: + o3 #EXEC {:G3: %-1}
This gives the same result.
I did actually try to make seperate aliases as well, but even that gave me issues (I reported that one from within CMud).
I found a way to get things to work, but I do hope this kind of overriding will be possible.
The work-around I use is to have the kt alias raise an event, for which each window can then handle - that works, but without a default. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Dec 12, 2007 12:33 am |
OK, try this instead. It actually uses the preferred #WINDOW syntax anyway:
Code: |
#ALIAS o3 {#WINDOW G3;#EXEC %-1} |
The #WINDOW command should properly change the context. |
|
|
|
Voltz-dk Beginner
Joined: 28 Nov 2007 Posts: 15
|
Posted: Wed Dec 12, 2007 2:50 am |
Still no go. If I write it as you did, it just switches window (an undesired effect) and sends the command to the previous window(from where I typed the o3 alias).
If I try variations, such as "#WINDOW G3 {#EXEC kt}", #EXEC kt is just displayed as local text in G3. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Dec 12, 2007 5:22 am |
Voltz-dk wrote: |
#EXEC kt is just displayed as local text in G3. |
Just fyi, this is the proper behaviour of the #window command, not an error. Read the help. |
|
|
|
|
|