|
SomeGuy Newbie
Joined: 05 Jan 2017 Posts: 4
|
Posted: Thu Jan 05, 2017 10:09 pm
Newbie Alias/Variable question, coming from Zmud |
In Zmud I had a very very basic alias, that I cannot for the life of me replicate in CMud
#ALIAS k {#VAR target %1;kill @target;speed up}
In Zmud, I could type k rabbit, and it would send the following
kill rabbit
speed up
I could then type k all by itself, and it would repeat the above
kill rabbit
speed up
however in CMUD it overwrites the variable with a null value if I re-send the command without a parameter. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Jan 06, 2017 2:48 am |
You could just check if %1 is not null before overwriting your variable:
Code: |
#alias k {#IF (%1 != %null) {#VAR target %1};kill @target;speed up} |
|
|
|
|
SomeGuy Newbie
Joined: 05 Jan 2017 Posts: 4
|
Posted: Fri Jan 06, 2017 2:00 pm |
Daern wrote: |
You could just check if %1 is not null before overwriting your variable:
Code: |
#alias k {#IF (%1 != %null) {#VAR target %1};kill @target;speed up} |
|
That's exactly what I would like to do, but when trying to use your code it errors on having an Extra Brace. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Jan 06, 2017 3:27 pm |
No brace issue in his code....
Did you enter it on the command line, or try to insert it into your preexisting alias? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
SomeGuy Newbie
Joined: 05 Jan 2017 Posts: 4
|
Posted: Fri Jan 06, 2017 3:39 pm |
shalimar wrote: |
No brace issue in his code....
Did you enter it on the command line, or try to insert it into your preexisting alias? |
I pasted it to the command line, and got this error screen.
|
|
|
|
SomeGuy Newbie
Joined: 05 Jan 2017 Posts: 4
|
Posted: Fri Jan 06, 2017 3:43 pm |
Ok, I resolved it this way.
#ALIAS k {#IF (%1 != %null) {#VAR target %1;kill %1;speed up};{kill @target;speed up}}
I tested and it's working now.
|
|
|
|
|
|