|
MARTINX Beginner
Joined: 11 Oct 2000 Posts: 13
|
Posted: Fri Jun 08, 2007 3:24 pm
Aliases, Macros and Variables Override |
Ok I want to do some OO style programming with CMUD basically I want to do this:
I have a common package which contains default functions and basic macro associations for directions, directions are stored into variables and assigned to keypad so that KEY6 will fire the "moveEastCommand" alias that will expand "eastCommand" variable containing the "east" value. All of this works fine.
Now let's say I log my thief, and my thief class package, I want my thief to sneak every direction I type so the best thing to do would be to override the "eastCommand" variable and set its value to "sneak;east", but I don't want to rewrite all the aliases and macros again for each class. There's any way in cmud to implement functions override or any workaround? |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Jun 08, 2007 6:53 pm |
The best approach, in my mind is to have several modules Thief, Warrior, Cleric etc that each define the eastCommand etc. When you sign on to a particular particular enable the commands accordingly. You could also try doing something with priorities but that will be hard.
Alternatively you can define the alias you want to override the change to a specifc class or module so that you overridden alias is always the first one found in the scope. A bit of kludge but should do what you want.
Ultimately I don't know if you'll get the OO style of packages you want, and it certainly won't happen before package dependencies are developed. |
|
_________________ Asati di tempari! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Jun 08, 2007 10:06 pm |
Perhaps a much easier way to do the above:
#oninput {({north|south|east|west})} {#sub sneak;#exec %1}
Since only the thief needs to sneak before moving, you can just define that trigger in your thief package and not have anything for the other ones.
EDIT: Might need to change the pattern to "^{({north|south|east|west})}$", your choice. |
|
|
|
|
|