Channel name background

By knoeki on May 07, 2010

Screenshots

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
        }
    }
}

Comments

Sign in to comment.
DashRipr0ck   -  Feb 20, 2018

Old script?
if ($findfile($scriptdiretc\chanimg\, $+($chan,.bmp), 1, 1) == $null)
..BMP???
Looks like Exonyte's script.

 Respond  
knoeki   -  May 09, 2010

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.

 Respond  
Jethro   -  May 08, 2010

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.

 Respond  
knoeki   -  May 08, 2010

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.

 Respond  
Jethro   -  May 08, 2010

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 }
 Respond  
cessil   -  May 08, 2010

love it, I added this to mine

      .background -p $chan $mircdir $+ \graphics\ $+ $chan $+ .bmp

so it sets the background for me

 Respond  
WorldDMT   -  May 08, 2010

what about $exists or $isfile and you can replace == $null by adding "!" before the identifer

and remove the "()" around the condition it will make the code slower

 Respond  
knoeki   -  May 07, 2010

I guess that's mostly to blame for ripping it from full on JOIN event I use, which does a number of other things when someone joins.

 Respond  
Jethro   -  May 07, 2010

on *:JOIN:#: {
if ($nick == $me) {can just be:

on me:*:JOIN:#: {

you save yourself an if statement and a bracket.

I'm not saying the nick = me is a bad usage; it's just there's no true and false comparison.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.