|
Arioch Newbie
Joined: 06 Oct 2008 Posts: 2
|
Posted: Mon Oct 06, 2008 3:49 pm
alias in a variable called by a trigger |
Something I used to do in tt++ (and zmud) that I can't seem to get to work in CMud was have a floating alias in a variable I wanted to do ad nauseum (mainly casting the same spell on the same target over and over and over) .. Here's how I did it in tt++:
#alias heal {cast 'heal' %0}
#alias rmm {rest;mem;medit}
#var circle heal
#var target BigTank
#trigger {^You complete your spell} {rmm}
#trigger {^Your studies are finished} {stand;$circle $target}
The 2nd trigger line sends the actual text "heal BigTank" to the mud instead of expanding the variables and reparsing the line for aliases. Is this possible in cmud? I've gotten it to work by setting the @circle variable to be the whole line "cast 'heal'" instead of the alias, but that's annoying to do in more complex scenarios. Ultimately I want to add a set number of loops for this, but getting this to work initially will be a start. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Oct 06, 2008 4:44 pm |
This is working fine for me in CMUD 2.36 - this was an issue in previous versions, but it works for me. Here's the code I used to check:
#alias test {stand;@circle blue}
circle=lol
test
Which sends "stand" and "lol blue" to the MUD.
More likely your issue is related to your improper use of local variables. Local variables only hold a value during the script block they're defined in - so because the $circle and $target local variables haven't been given a value during the trigger, they'll have no value. Because neither $circle or $target has a value, you see nothing being sent to the MUD. You probably meant to use non-local variables, which are set with the syntax like circle=lol like I demonstrated above, or with the #var command, and referred to with the @circle syntax, which I also used above. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Oct 06, 2008 4:55 pm |
Fang is right about your misuse of local variables, $circle, instead of non-local variables, @circle. But from what you have said, I think that is merely a typo in your posting. It sounds like what you want to happen is to have it expand another level, so that the @circle value of heal is interpreted as the alias heal. This is done with the #exec command. Try this for your trigger:
Code: |
#trigger {^Your studies are finished} {stand;#exec @circle @target} |
|
|
|
|
Arioch Newbie
Joined: 06 Oct 2008 Posts: 2
|
Posted: Mon Oct 06, 2008 5:04 pm |
The initial code was a tt++ reference, which used $ instead of @. my cmud code was properly syntaxed (i.e. @circle @target), it just wasn't expanding another level. I'll try #exec and see if it works. Ok, #exec looks to be what I needed to make this work. Thanks for the tip!
|
|
|
|
|
|