Simple little script that put the name of the channel in the top right corner, as a background image, see screenshot.
The image is generated once, when you join the channel for the first time. After this, images are re-used if needed.
If you want, you can change the font and size by editing the %font.face and %font.size variables. Please note that if you change them, you'll need to remove any previously generated images, so that they'll be re-generated with the updated settings.
Also, make sure to have a directory of \etc\chanimg\ in whatever folder the script is in, otherwise it may not work.
on *:JOIN:#: {
if ($nick == $me) {
if ($findfile($scriptdiretc\chanimg\, $+($chan,.bmp), 1, 1) == $null) {
var %font.face Arial
var %font.size 72
var %w $calc($width($chan, %font.face, %font.size) + 10)
var %h $height($chan, %font.face, %font.size)
window -dpfh @chantext 1 1 %w %h
drawtext -r @chantext $rgb(25, 25, 25) %font.face %font.size 1 1 $chan
drawsave -b16 @chantext $qt($+($scriptdiretc\chanimg,$chan,.bmp))
window -c @chantext
}
}
}
Actually knoeki, speed aside, WorldDMT's suggestion of using $exists() or $isfile() is recommended, because you want to make sure the file the script references to is there. If not, you may get an error. That's why people make checks to prevent errors from happening.
That's what the $findfile() is for.. again.. I must have had some reason to use that over $file() (or $isfile() or $exists() for that matter), but I really don't know why I didn't use it. May or may not have to do with the fact that I ripped this from a larger script I wrote.
what about $exists or $isfile
could have done that, I'm sure I had a reason not to do so.and you can replace == $null by adding "!" before the identifer
Not my style, sorry.and remove the "()" around the condition it will make the code slower
I really doubt it matters much, and if it does, then stop using the dusty old 486 in your mums basement as your PC (:
I prefer my code to be readable over "fast", especially when there's no real significant speed gain... 1ms more or less is not going to kill you with something trivial as this.
remove the "()" around the condition it will make the code slowerWorldDMT, I have heard many people state that don't use curl brackets or parentheses around a string of code.
What difference does it make speed wise if I make something, for example, like this:
if (speed == WorldDMT) hello $v2
OR
if speed == WorldDMV { hello $v2 }
Is there a really scientific proof that one of them does run faster against one another?
Perhaps we just do it formally then:
if (speed == WorldDMT) { hello $v2 }