Help with non-boolean values

Post Reply
n60cowgirl
Posts: 2
Joined: Mon Apr 09, 2012 2:49 pm

Help with non-boolean values

Post by n60cowgirl »

Hi! Long time lurker, first time poster!

So I want to make a shorter alias for Achaea Alchemy extracting in the form of "ext [s/u/m]", where typing "s", "u", or "m" would extract salt, sulphur or mercury, respectively. The match pattern I got in the alias is
Code: [show] | [select all] lua
^ext (.*)$
and what I call up in the big box is
Code: [show] | [select all] lua
shorten_extract()
. What I surmised from browsing the manual is that I should try making a function and here's what I got so far:
Code: [show] | [select all] lua
function shorten_extract()
if matches[2] = "s" then send("extract salt")
elseif matches[2] = "u" then send("extract sulphur")
elseif matches[2] = "m" then send("extract mercury")
else echo("Which Prime do you mean? "S" for Salt, "U" for Sulphur, "M" for Mercury")
end
Heh, yeah. So that's not working! Would appreciate some experienced wisdom! Thanks!

DevArrah
Posts: 51
Joined: Sat Oct 29, 2011 4:57 pm

Re: Help with non-boolean values

Post by DevArrah »

I haven't tested it but i don't think you can access matches from the function since it's not in the trigger script


try
shorten_extract(matches[2])

function shorten_extract(prime)
if prime=='s' ...


also please note that = is an assignment operator,,, you are attempting to set matches[2] equal to 's'... what you want want is the equality operator ==

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: Help with non-boolean values

Post by Iocun »

You can access the matches table from everywhere, since it's a global variable, so that's not a problem (although I personally would write it with matches[2] as an argument too as DevArrah mentioned).

The only syntactical problem is indeed the use of = instead of ==.

Post Reply