Trigger or Alias??

Post Reply
addie&ket2011
Posts: 19
Joined: Mon Aug 02, 2010 4:35 pm
Location: A deserted Island

Trigger or Alias??

Post by addie&ket2011 »

Hello,

I'd like to have my character on Imperian while bashing pick up the corpses and gold dropped after i have killed them.

Is this one that is more easier as a trigger??

i.e.
"You have slain (\w+)"
send ("get (\w+)")
send ("get gold")

or as an alias

^gcorpse$
commands:
send ("get corpse")
send ("get gold")

or, pick them up if i do IH, then do "gg" which will pick up gold and corpses..

alias: ^gg$
send ("ih")

bit lost, and a bit new to programming in LUA

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Trigger or Alias??

Post by Heiko »

pattern: "You have slain (\w+)" (Don't forget to select perl regex pattern otherwise (\w+) will not work as expected!)
script:
send ("get " .. matches[2] )
send ("get gold")

(\w+) is perl regex lingo and makes no sense in Lua scripts. In your scripts you'll need to refer to the capture groups via the matches[n] table where matches[2] is the content of the first capture group, matches[3] the content of the second etc. (matches[1] is the complete match of your regex expression)

addie&ket2011
Posts: 19
Joined: Mon Aug 02, 2010 4:35 pm
Location: A deserted Island

Re: Trigger or Alias??

Post by addie&ket2011 »

okay.

so for the matches[n], how would i set them up?? as a separate alias set up for target??

A bit confused.

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Trigger or Alias??

Post by demonnic »

the matches table is provided for you by the trigger. When it matches

^You have slain (.+)$

then essentially everything after "You have slain " is captured as matches[2]


If you have multiple matches, such as with

^(\d+)h, (\d+)m

then the health would be matches[2] and the mana would be matches[3]

addie&ket2011
Posts: 19
Joined: Mon Aug 02, 2010 4:35 pm
Location: A deserted Island

Re: Trigger or Alias??

Post by addie&ket2011 »

thanks a lot!!

Post Reply