Calling wildcards in if-trees

Posted by Rainava on Fri 01 Oct 2010 08:33 PM — 3 posts, 12,396 views.

#0
I have the following trigger:

<triggers>
<trigger
custom_colour="17"
enabled="y"
group="combat"
ignore_case="y"
match="^(\w+) slowly raises (his|her) head and you see (his|her) eyes glowing bright white.$"
regexp="y"
send_to="12"
sequence="100"
other_text_colour="white"
>
<send>local target

target = GetVariable("target")

if target == "%1" then
SetVariable ("target", "nothing")
else
end</send>
</trigger>
</triggers>

What I want is: if the current value of my variable "target" is George, and I see "George slowly raises his head and you see his eyes glowing bright white.", I want to change the target to "nothing" instead. But it doesn't seem to work.

I know the trigger is firing generally (I tested adding a line saying to execute some other command if something other than George was the value of "target" and it worked) and I clicked the 'Ignore case' box, so case isn't the issue. I'm guessing the problem is that it's interpreting %1 as the actual target name I'm asking for, rather than as a wildcard calling whatever the word was in the trigger line. Is there any way to make this work?
USA #1
Rainava said:
What I want is: if the current value of my variable "target" is George, and I see "George slowly raises his head and you see his eyes glowing bright white.", I want to change the target to "nothing" instead. But it doesn't seem to work.

I loaded your trigger up, set a 'target' variable to 'George', and used Simulate("George slowly raises his head and you see his eyes glowing bright white.\r\n") to test it, and it worked fine. I checked the 'target' variable and it had been set to 'nothing'.

Can you explain what you mean by "doesn't seem to work"? Does the variable not get set? Make sure the value of the variable is 'George', not 'george'. If the wildcard and the variable don't match exactly, it won't work. To make sure that's not the problem, you should make sure both are lowercase:
local target = GetVariable("target")
if string.lower(target) == string.lower("%1") then
  SetVariable("target", "nothing")
end
#2
Ohh. I had thought clicking the "Ignore case" box would be adequate but I guess that only works on recognizing the trigger, not everything. That makes sense.

Did what you said and it works now. Thanks so much! The "string.lower( )" bit will make a lot of things easier.