Need help for a tracking script

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Need help for a tracking script

Post by Vadi »

Oh. Yes, there is a bug with cecho and insertText, Babelfish knows about that one.

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Need help for a tracking script

Post by syrik »

Ok, thanks, I will see if this works and post if I have problems :)

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Need help for a tracking script

Post by syrik »

ok, heiko's is this:

Trigger: You see fresh tracks of a (\w+) leaving (\w+). (perl regex I take it)


Script:
local markRef = {}
markRef["north"] = "^^north^^"
markRef["east"] = ">>east>>"
markRef["south"] = "VVsouthVV"
markRef["west"] = "<<west<<"
selectCaptureGroup(3)
replace(markRef[matches[3]])

On this one, simply nothing happens.


tsuujin's does this:

trigger:You see fresh tracks of a (\w+) leaving (\w+). (also perl regex I assume)

Script:

local markRef = {}
markRef["north"] = "^^"
markRef["east"] = ">>"
-- Et cetera for all directions
deleteLine()
cecho(string.format("\n<white>There are some <red>bloody tracks of %s headed %s %s %s."matches[2],markRef[matches[3]],matches[3],markRef[matches[3]]))

When I try to activate it, the ladybug says: Lua syntax error:[string "function Trigger60.."]:7:')' expected near matches'

Any help would be awesome!

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

Re: Need help for a tracking script

Post by Heiko »

1. If my script doesn't work then your regex is wrong.
Use the highlighter option to see what's really matching your regex or print the result of matches[3]. The script only works correctly, if the second capture group evals to "north", "west", "south" or "east". Anything else will cause an error.
2. It's usually better to use the error view (red ! button) instead of the debug console (lady bug button).
3. A full stop becomes \. in regex.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Need help for a tracking script

Post by tsuujin »

looks like mine is missing a comma between the sting and the first argument within string.format

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Need help for a tracking script

Post by syrik »

Ok heiko, I just copied/pasted a line into the trigger line and set as an exact match to make sure that my pattern was correct. This is what it says in the debug console:

new line arrived:Outside a Massive Gate

new line arrived:[ Exits: n e s w ]

new line arrived:You see fresh tracks of a trolloc leaving east.

Trigger name=Tracking(You see fresh tracks of a trolloc leaving east.) matched.
match state 3/3 condition #0=true (0/2) regex=You see fresh tracks of a trolloc leaving east.
new line arrived:You see fresh tracks of a trolloc leaving east.

Trigger name=Tracking(You see fresh tracks of a trolloc leaving east.) matched.
match state 4/4 condition #0=true (0/2) regex=You see fresh tracks of a trolloc leaving east.

So it is matching everything, but it doesn't seem to be doing anything.
This is what it says in the mud:

Outside a Massive Gate
[ Exits: n e s w ]
You see fresh tracks of a trolloc leaving east.
You see fresh tracks of a trolloc leaving east.
You see almost fresh tracks of a trolloc leaving east.

and this is the script:

local markRef = {}
markRef["north"] = "^^north^^"
markRef["east"] = ">>east>>"
markRef["west"] = "<<west<<"
markRef["south"] = "VVsouthVV"
-- Et cetera for all directions
selectCaptureGroup(3)
replace(markRef[matches[3]])

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

Re: Need help for a tracking script

Post by Heiko »

Post a screenshot of your trigger because you've somehow messed up the settings. You are using a multistate AND trigger with 3 conditions according to your debug output instead of a regular 1 state trigger with a single regex condition :D

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Need help for a tracking script

Post by tsuujin »

Heiko wrote:Post a screenshot of your trigger because you've somehow messed up the settings. You are using a multistate AND trigger with 3 conditions according to your debug output instead of a regular 1 state trigger with a single regex condition :D
He and I fixed this some time ago. Unless there's a new issue, this can be marked solved.

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Need help for a tracking script

Post by syrik »

if anyone wants this scipt, let me know.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Need help for a tracking script

Post by Vadi »

Just post it up, not everyone registers to post

Post Reply