Using a variable with an alias script

Posted by Errigour on Fri 01 Aug 2014 11:14 AM — 6 posts, 25,589 views.

USA #0
I am trying to do the following but this isn't an accetable format and wildcards(1) returns an error on nil.

The alias is : sanc*


if  %1 == nil  then
  Send("cast 'sactuary' name")
else
  Send("cast 'sactuary' %1")
end
Amended on Fri 01 Aug 2014 11:34 AM by Errigour
USA Global Moderator #1
Quote:
wildcards(1) returns an error on nil

wildcards[1]

wildcards is a table, not a function.
USA #2
Also, it looks like you misspelled 'sanctuary'.

(and also 'acceptable', but that shouldn't affect your script. :) )
USA Global Moderator #3
Also, what is name? Is that meant to be a variable?
Australia Forum Administrator #4
It looks like you are using send-to-script in which case %1 will just be nothing if it doesn't match. So closer to what you want would be:


if  "%1" == ""  then
  Send("cast 'sanctuary' " .. name)
else
  Send("cast 'sanctuary' %1")
end


Assuming "name" is a Lua variable with the person's name in it. Otherwise:


  Send("cast 'sanctuary' " .. GetVariable ("name"))


Template:faq=32
Please read the MUSHclient FAQ - point 32.


Also this one is close to describing what you are doing:

Template:faq=50
Please read the MUSHclient FAQ - point 50.
Amended on Fri 01 Aug 2014 08:06 PM by Nick Gammon
USA #5
Thanks!