|
Joined: Jan 2004
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2004
Posts: 6 |
I am not very good at scripting and I know this should be fairly simple.
I simply want to replace my text for certain words to say something different.
for example....if I type 'brnday' I would want it to display 'brandy' in the channel. I know it is probably a simple on INPUT script but I just dont know how to do it I'd also like to be able to add other words to be replaced. Answers ?
|
|
|
|
Joined: Apr 2003
Posts: 426
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 426 |
on *:INPUT:*:{ .msg $active $replace($1-,brnday,brandy) }
Thats an example.
For instance, you can use $replace to replace multiple times within the one text string.
Eg:
$replace(brnday: hello how are you,brnday,brandy,you,you?)
This would replace brnday with brandy, and you, with you?
This is how it works:
$replace(text string,word to replace,new word)
I hope that helps.
-------- mIRC - fun for all the family (except grandma and grandpa)
|
|
|
|
Joined: Jan 2004
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2004
Posts: 6 |
I don't know why, but that looks like it would work to me, but it just doesnt work..still comes out how I spelled it initially.
|
|
|
|
Joined: Jan 2004
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2004
Posts: 6 |
It did however make me repeat everything I said twice. I couldn't see it but it was shown to me after I thouroughly pissed a few people off
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
on *:INPUT:*: {
var %replacer = [color:Red]this,is,a,list,of,words,to,be,replaced[/color]
var %replace = [color:blue]this,is,what,they,should,be,replaced,with[/color]
var %r = 1, %msg = $1-
while ($gettok(%replacer, %r, 44) != $null) {
var %from = $ifmatch, %to = $iif($gettok(%replace, %r, 44), $ifmatch, %from)
var %msg = $replace(%msg, %from, %to)
/inc %r
}
/msg $active %msg
/halt
}
that should work a little better. Basically, set the first variable (marked with red) to the word being replaced, and the blue portion to the one to replace it with. Seperate the sections with commas. For example, if you wanted all the instances of "cat" to change to "dog", and "fish" to change to "parrot", you could use: var %replacer = cat, fishvar %replace = dog, parrot
-KingTomato
|
|
|
|
Joined: Jan 2004
Posts: 26
Ameglian cow
|
Ameglian cow
Joined: Jan 2004
Posts: 26 |
" ...make me repeat everything I said twice... "
that happens if another remote script you are running is also triggered by on INPUT { say $whatever($1-) } .
The ^ Prefix (/help Halting default text) is not supported here. AFAIK the only thing you can do is to find that 2nd on INPUT event (search all *.mrc, *.ini et cetera for ":INPUT:" (without quotes)) , then unload / delete or modify it (e.g. put a ; before /say).
|
|
|
|
Joined: Dec 2003
Posts: 33
Ameglian cow
|
Ameglian cow
Joined: Dec 2003
Posts: 33 |
edit: oops, nm just use what KingTomato has put in.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
better than editing the other scripts just do this... alt-r / remotes / file / order / select KingTomato's script file / move it to the top of the order. His well no run first, and void all the ones following as his is on *:input:*: which catches all input if im not mistaken. one other thing you might consider is this.
on *:INPUT:*: {
if (%replacer.block == $true) { set %replacer.block $false }
else {
var %replacer = this,is,a,list,of,words,to,be,replaced
var %replace = this,is,what,they,should,be,replaced,with
var %r = 1, %msg = $1-
while ($gettok(%replacer, %r, 44) != $null) {
var %from = $ifmatch, %to = $iif($gettok(%replace, %r, 44), $ifmatch, %from)
var %msg = $replace(%msg, %from, %to)
/inc %r
}
/editbox -an %msg
set %replacer.block $true
/halt
}
Same routine, just it loads the editbox with the result, then sets a flag to say dont process the next line comming through (being the editbox loaded line), then halts the current lines processing, on the next pass the line doesnt get processed and the flag gets cleared, this well allow what ever other ON INPUT routines in other scripts to also get to process the line. I only said this, as i wrote a on input routine to decapatilize lines, and then it screwed up something someone elses did below it, as theres never got a chance to run.
|
|
|
|
Joined: Jan 2004
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2004
Posts: 6 |
King Tomotoes script works ~almost~ perfectly. But when I do an action
/me does whatever is displayed in the channel.
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
good catch, i forgot about that >:D
on *:INPUT:*: {
if ($left($1, 1) !isin $+(/,$readini($mircini,text,commandchar))) {
var %replacer = [color:Red]this,is,a,list,of,words,to,be,replaced[/color]
var %replace = [color:blue]this,is,what,they,should,be,replaced,with[/color]
var %r = 1, %msg = $1-
while ($gettok(%replacer, %r, 44) != $null) {
var %from = $ifmatch, %to = $iif($gettok(%replace, %r, 44), $ifmatch, %from)
var %msg = $replace(%msg, %from, %to)
/inc %r
}
/msg $active %msg
/halt
}
}
that should fix it. Sorry for the foul up. >:D
-KingTomato
|
|
|
|
Joined: Jan 2004
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2004
Posts: 6 |
Thanks loads. I tried to fix it myself because I could see it was sending as a /msg but I couldn't do it. I tried
if(/me isin $1-) {/describe $active $1-}
etc...you can see where that would go wrong. But anyway its working now, and not interfering with any other remotes that I have found yet. So thanks.
Uhm, I hate to even ask this, but how would I modify it to also replace words on *:ACTION:*
etc..
?
|
|
|
|
|