trigger help

Post Reply
tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

trigger help

Post by tarrant »

J~<rNukes: [0/3]> <vAir Drop: [3/3]> Reset: [63%] Suit: Salamander
Code: [show] | [select all] lua
	if x.value:find("J~<rNukes: [(%d+)/(%d+)]> <vAir Drop: [(%d+)/(%d+)]> Reset: [(%d+)%] Suit: (%w+)") then
		nukesCur = x.value:match("<rNukes: [(%d+)")
		nukesMax = x.value:match("(%d+)]> <vAir Drop:")
		adropCur = x.value:match("<vAir Drop: [(%d+)")
		adropMax = x.value:match("/(%d+)]> Reset")
		reset = x.value:match("Reset: [(%d+)%]")
		suitCur = x.value:match("Suit: (%w+)")
		clearUserWindow("StatusBar2")
		cecho("StatusBar2","<white>[<LightSeaGreen>M<light_slate_grey>:<LightSeaGreen>" .. nukesCur .. "<white>/<LightSeaGreen>" .. nukesMax .. "<white>][<LightSeaGreen>C<light_slate_grey>:<LightSeaGreen>" .. adropCur .. "<white>/<LightSeaGreen>" .. adropMax .. "<white>][<LightSeaGreen>R<light_slate_grey>:<LightSeaGreen>" .. reset .. "%<white>]")
	end
I have these 2 if/then statements within a certain trigger. For some reason i can't deduce, the code in the above box doesn't work, but the code in the box below does even though they seem the same to me. Can anyone see if there's something wrong with the above code? Or what difference is causing this?
K~A Small Nightmare Cow Herd~L~74~
Code: [show] | [select all] lua
	if x.value:find("K~([^~]+)~L~(%d+)") then
		mobName = x.value:match("K~([^~]+)") 
		mobHealth = x.value:match("L~(%d+)")
		clearUserWindow("StatusBar5")
		cecho("StatusBar5","<white>[<purple>E<light_slate_grey>:<magenta>" .. mobName.. "<white>:<purple>" .. mobHealth .. "%<white>]") 
	end

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: trigger help

Post by Yetzederixx »

I'm a bit of a noob here, but why aren't your doing it like this?

Nuke stuff:
Code: [show] | [select all] lua
Pattern: ^J~<rNukes: \[(\d+)/(\d+)\]> <vAir Drop: \[(\d+)/(\d+)\]> Reset: \[(\d+)%\] Suit: (\w+)$

nukesCur = matches[2]
nukesMax = matches[3]
adropCur = matches[4]
adropMax = matches[5]
reset = matches[6]
suitCur = matches[7]

-- your cecho seems to be in order, this might help you out
Cow stuff:
Code: [show] | [select all] lua
Pattern: ^K~(.*)~L~(\d+)~$

mobName = matches[2] 
mobHealth = matches[3]

Post Reply