Problem with ~= operator

Posted by Aidyn.Hartfire on Mon 11 Aug 2008 02:02 AM — 4 posts, 17,609 views.

USA #0
Alright, I'm trying to create a simple trigger that will take away a given defense when the person who puts it up is the person I am targeting. The trigger fires, however, the secondary clause doesn't seem to want to evaluate itself. Therefore, I have come here--again--to see what rookie mistake I have made. Here is the code:




if %1 == @tar then
   ColourNote ("red", "black", "<<<SHIELDED-RAZE-SHIELDED>>>")
   DoAfter (3, "raze @tar")
elseif %1 ~= @tar then
   ColourNote ("blue", "black", "<<<IS THERE DANGER?>>>")
end--if



I tried to change the "elseif" to just "else" but all it would return is:



Compile error
World: Lusternia
Immediate execution
[string "Trigger: "]:4: '=' expected near '~='


Any suggestions?
Netherlands #1
I am assuming your %1 exists out of multiple words, which would mean it would look like 'if multiple words ~= contents_of_tar then'.

The best solution is to make sure both %1 and @tar have quotes around them like "%1" and "@tar".

Good luck.
USA #2
Yeah, someone just helped me out. As for the wildcard, this is one instance where it is actually only one word. Anyhow, thanks for the help. Your reply was actually the same solution I got from a friend. Thanks again!
#3
Incidentally, I found " to be far too common a character about, and tend to use the more robust Lua quotes for stuff like pattern matches and variables:
[[%1]], [[@tar]], [[quoted string]]

This type of quote allows newlines and basically every character sequence except the terminating ]]. (I think.)