|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
I'm trying to get a hotlink event to change the mouse cursor over a word or phrase that is in the middle of a line, but the word/phrase won't always be the same. Any suggestions for the matchtext in the on hotlink event?
Example: [UnderNet] Successfully Received Spotted Aluris.png [25.2kB] from Sporeman at 25.2 Kbs at 8:27pm.
The creature file (from Spore, if you're interested) is the filename after Received and before the [. I want to be able to just click it to open the image to view it. I can handle the code to make it open, but I can't figure out how to make it highlight all words after Received (or starting at token 4) up until the [. Any suggestions?
Basically, I just need a way to use hotlink based on tokens and I'll be fine. Right now, $1 is always the current word and it doesn't seem to take into account anything else, which is a problem, I think. I can make it actually opens the file correctly in the second part of the on HOTLINK, but I really want to have the mouse change over the entire name.
Last edited by Riamus2; 20/07/08 03:53 PM.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
on ^*:hotlink:*:*:{
var %fnstart = 4, %wordpos = $gettok($hotlinepos, 1, 32)
if (%wordpos < %fnstart) halt
if ($regex($hotline, /^\[.+?\] Successfully Received (.*) \[.+?\] from \S+ at \S+ \S+ at \S+$/)) {
var %fnend = $calc(%fnstart + $numtok($regml(1), 32) - 1)
if (%wordpos !isnum $+(%fnstart, -, %fnend)) halt
}
else {
halt
}
}
on *:hotlink:*:*:{
if ($regex($hotline, /^\[.+?\] Successfully Received (.*) \[.+?\] from \S+ at \S+ \S+ at \S+$/)) {
; DO SOMETHING HERE - $regml(1) contains the filename
}
} I was a bit wary of using regex matching in a hotlink event like that, but it doesn't seem to be a problem even on a modestly powered laptop. Just the same, if it's practical you should change the window matching section of the hotlink event to the specific windows/channels you'll use it on.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Another solution:
;[UnderNet] Successfully Received Spotted Aluris.png [25.2kB] from Sporeman at 25.2 Kbs at 8:27pm.
on ^*:HOTLINK:*:*:{
var %r = $sporehotline($1,$hotlinepos,$hotline)
if (!%r) halt
}
on *:HOTLINK:*:*:{
var %r = $sporehotline($1,$hotlinepos,$hotline)
if (%r) echo -a $gettok($hotline,%r,32)
}
alias sporehotline {
;$1=$1, $2=hotlinepos, $3=$hotline
if (!$isid) { echo -a $!sporehotline must be used as identifier | return 0 }
var %a = $findtok($3,Received,1,32)
if (!%a) return 0
inc %a
var %z = $findtok($3,from,1,32)
if (!%z) return 0
dec %z 2
if ($gettok($2,1,32) isnum $+(%a,-,%z)) return $+(%a,-,%z)
return 0
}
This code has the possibility of being inaccurate if the word "from" is in the filename. -genius_at_work
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
That works really well. Thanks.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|