help with SelectString and replace

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

help with SelectString and replace

Post by Caled »

H:4661|3492 100% Exp:47 <kcsdb eb <<< ARM BALANCE >>>> 100|100

A sample of my prompt ^
I want to replace <<<ARM BALANCE>>> with
lr
(Eventually I will want to replace it with the contents of the variable "armb" but for now just the string "lr" is enough, because I have not yet written the script that populates armb with meaningful values.)

Code: Select all

Pattern is a substring of the line: <<< ARM BALANCE >>>
Script:
selectString( "<<< ARM BALANCE >>>" )
replace( "lr" )
I think that ought to work, but it does not. Help will be appreciated.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: help with SelectString and replace

Post by Caled »

I'm having trouble with selectString in general, I think.

Code: Select all

Pattern: You have recovered equilibrium.
Script:
selectString( "You have recovered equilibrium." )
fg( "blue" )
I tried the above with various different pattern types (Pattern starts at beginning of line, pattern is entire line, and regex "^You have recovered equilibrium\.$"). It never colours the line.

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

Re: help with SelectString and replace

Post by Heiko »

Caled wrote:I'm having trouble with selectString in general, I think.

Code: Select all

Pattern: You have recovered equilibrium.
Script:
selectString( "You have recovered equilibrium." )
fg( "blue" )
I tried the above with various different pattern types (Pattern starts at beginning of line, pattern is entire line, and regex "^You have recovered equilibrium\.$"). It never colours the line.
You made a syntax error. It's selectString( what, numberOfMatch )

Code: Select all

Pattern: You have recovered equilibrium.
Script:
selectString( "You have recovered equilibrium.", 1 )
fg( "blue" )
explanation:
Let's assume the line Tom gets a ride to Tom's house.
selectString( "Tom", 1 ) will select the first occurence of Tom
selectString( "Tom", 2 ) will select the second Tom in the line.

General Tip for debugging your triggers: Use the debug console (-> click on the bug icon in trigger editor)
This will give you a truckload of info on what is the current line, what trigger matched, what the capture groups contain, what scripts ran etc..

Here is a link to the latest version of the manual that is updated regularly:
http://mudlet.git.sourceforge.net/git/g ... ml;hb=HEAD

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: help with SelectString and replace

Post by Caled »

Ah of course. A silly mistake, thanks for the help.

And thanks for the tip about the debug report, I didn't know it existed.

Post Reply