"Variable 'target' not defined"

Posted by Tatewaki2365 on Sun 09 Jan 2005 06:57 AM — 14 posts, 46,735 views.

#0
Alright, I gave up on the task not too long ago of having an alias/targetting system. But recently, after intense annoyance, I find myself crawling back.

I've been looking into trying to make an alias for summon (Syntax being: co 'summon' [person]), but using summ as an alias for that. When I was toying around with something I found on the site, it led me to look at this: ^(kick|punch|stab) and then send at %1 @target. I thought that might help with figuring out how my alias system could work, but when I typed in kick through Mush, it gave me the message "Variable 'target' not defined". So, if anyone would like to share the solution to my dilemma...

Want: 'summ' to be used as alias for [co 'summon'] and then be able to insert a target using the tar [person] command.

Have: An error...
USA #1
"variable 'target' not defined" simply means that a variable named literally "target" does not exist.

You use that when you send %1 @target. The @target is the contents of the variable target (assuming you have expand variables checked).

You just have to create a variable "target" and set it to something (which could be done via an alias).

To set it, you'd have your 'tar *' alias, which you 'send to' variable, fill the "variable" box in with "target" and then type "%1" (no quotes) in the 'send' box.

Or if you needed to do anything else with that alias, you could 'send to': script, and then enter 'setvariable "target", "%1"' (no single quotes) into the send box (assuming you were using VB).
#2
I did what I could that you said, but ultimately came up with the same error.

Alias set for target: tar *
Send: %1
And I have expand variables, send to variable and the variable 'target' box filled with target.

Then, on an alias of my own, I have: weak
send: co 'weak' %1 @target
And expand variables checked again.
Australia Forum Administrator #3
Can you copy and paste the actual aliases, rather than reproducing them by hand? See here if you don't know how to do that:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4776

You have two aliases, the first should set up target, the second use it. The first one doesn't need to expand variables as it is setting one, not using one.

Once you have typed "tar blah" you should check the variables configuration window to make sure that the variable "target" contains "blah". If not, then you have a problem with your first alias.

This stuff does work, you know. It's just a case of doing it correctly.
#4
<aliases>
<alias
match="tar *"
enabled="y"
expand_variables="y"
variable="target"
send_to="9"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>


And this is WAY wrong, I'm sure


<aliases>
<alias
match="weak"
enabled="y"
expand_variables="y"
sequence="100"
>
<send>co 'weak' %1 @target</send>
</alias>
</aliases>
USA #5
The second alias needs a wildcard to match on. Right now you're trying to use %1 without ever having a wildcard.

Either that, or you need to remove %1 from your send (which you'd want to do if you only had weak in the alias).

So, if you want to use ^(kick|punch|stab)$ type of thing, then do so. Make sure regexp is checked, and I suggest ignore case as well.
And you'll want to remove the 'weak' in your send text as well. And if you need quotes around the action, you'll want to add those (co '%1' @target).

This is the former situation:

<aliases>
<alias
match="^weak$"
enabled="y"
expand_variables="y"
regexp="y"
ignore_case="y"
sequence="100"
>
<send>co 'weak' @target</send>
</alias>
</aliases>

This would be the latter:

<aliases>
<alias
match="^(weak)$"
enabled="y"
expand_variables="y"
regexp="y"
ignore_case="y"
sequence="100"
>
<send>co '%1' @target</send>
</alias>
</aliases>
Amended on Sun 09 Jan 2005 10:15 PM by Flannel
#6
Still... Getting... Same... Error. Blast.
#7
Alright, I'm starting to think it might be something with my target alias - this is what I have;

<aliases>
<alias
match="tar *"
enabled="y"
expand_variables="y"
variable="target"
send_to="9"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>
Poland #8
This alias is fine, at least it works fine for me.. probably what you need is to define that variable:)
So what you should do is go to configure variables (shift+ctrl+7), add a new variable, name it target, and give it any value. Afterwards, all should work fine..
USA #9
That shouldn't matter. Send to: variable (or setvariable for that matter) will create the variable if it isn't there.

But yes, adding that variable will solve your problem. Although you may not be able to change it via that alias if you currently can't create it. So we still have some sort of problem.
Australia Forum Administrator #10
That alias worked for me. You don't need 'expand variables' checked in the "tar *" alias, as I said before.

Try it on its own. Type "tar blah" and then check if the variable is defined. The only reason I can think of is that there is *another* alias that is acting first.

Turn "Trace" on from the Game menu and then try the alias. You should see something like this:


TRACE: Trace on
TRACE: Matched alias "tar *"
#11
Yeah, there was a conflicting alias.

So, as a final question - is there a way to turn it off easily without having to go to aliases and disabling them all? Perhaps a way to just make it clear out the target name so it goes from 'tar [name]' so it casts co 'blind' [name], to co 'blind'. The latter would be useful for when I'm blinded and can't target.
#12
I hate posting so much, so I'll stop here... But, it seems that when you do tar ' it places the target as the current person you're in battle with.

Thanks for the help!
USA #13
What are you asking? Turn what off?

If you have "keep evaluating" checked on your aliases, you wont have the conflicts, as they will all be able to match.

As for casting with or without an argument, you could do something as simple as just setting your target to "", which would make you cast "co 'blind' ". There is a space at the end, but depending on your server, it may or may not care.