Problem getting a variable from trigger

Posted by Orogan on Sat 20 Mar 2010 08:45 PM — 5 posts, 22,256 views.

#0
Hello all

My triger is


	<trigger
	 name="AuctLine"
	 group="auction"
	 enabled="y"
	 match="^Auction: (?P<sell_name>.*?) is auctioning.*$"
	 regexp="y"
	 ignore_case="y"
	 expand_variables="n"
	 script="auction_to_gt"
	 send_to="12"
	 sequence="10"
	>
	</trigger>



It triggers on something like:

Auction: Seller is auctioning an item (Level lvl 10, Num 111). Current bid is 100.

the trigger fires but when I try to use the variable it say's its a nil value.

the function I use :


function auction_to_gt (name,line,wildcards,styles)
	if name == "AuctLine" then
		SellName = (GetAliasWildcard ("AuctLine", "sell_name"))
		Send ("gt " .. SellName)
        	return
	end -- if
end --auction_to_gt


the error msg I get:

attempt to concatenate global 'SellName' (a nil value)

I can't seem to find what's wrong with it, so any help greatly appreciated.
And if I'm going all wrong with this please say so.

Cheers
Orogan
Australia Forum Administrator #1
Orogan said:


function auction_to_gt (name,line,wildcards,styles)
	if name == "AuctLine" then
		SellName = (GetAliasWildcard ("AuctLine", "sell_name"))
		Send ("gt " .. SellName)
        	return
	end -- if
end --auction_to_gt



This is a trigger, and you are calling GetAliasWildcard. That gets alias wildcards. You meant GetTriggerWildcard.

You can simplify it anyway, like this:


function auction_to_gt (name,line,wildcards,styles)
  if name == "AuctLine" then
    Send ("gt " .. wildcards.sell_name)
    return
  end -- if
end --auction_to_gt


The wildcards array, passed to this function will have the named wildcard there, you don't need to use GetAliasWildcard or GetTriggerWildcard.

And if this function is only ever called by that one trigger, just do this:


function auction_to_gt (name,line,wildcards,styles)
  Send ("gt " .. wildcards.sell_name)
end --auction_to_gt

#2
Ha ...
Thanks a lot.

That's what you get, when you use copy and past.

I'll use the simplified version makes it less complex.

The function won't be called only by that trigger, but thanks for the hint.


On a side note:Great program Nick,more support,improvement and so on then you could expect from a free program.

orogan
#3
Beyond great, I would say! :P lol Blows any other client out of the water, if you want my honest opinion. :D
Australia Forum Administrator #4
Thanks, both of you. :)