Some script experience assumed here...
Ping out realistically (by occupying mIRC so much that it can't send server pong back)
/pingout {
window @pingout
var %x = 0
while (%x < 1) { echo @pingout HA HA HA! I'm-a-gonna ping out! }
PI
/pi { return 3.1415926535897932 }
duration with years support
/xduration {
var %seconds = $1
var %duration = $duration(%seconds)
var %wks.pos = $pos(%duration,wks)
if (%wks.pos) {
var %wks.cnt = $mid(%duration,1,$calc(%wks.pos - 1))
if (%wks.cnt >= 52) {
var %years.f = $calc(%wks.cnt / 52)
var %years.i = $gettok(%years.f,1,46)
var %years = %years.i $+ $iif(%years.i == 1,yr,yrs)
var %wks.cnt = $calc(%wks.cnt - (%years.i * 52))
var %wks = %wks.cnt $+ $iif(%wks.cnt == 1,wk,wks)
var %result.wo = $gettok(%duration,2-,32)
var %result = %years %wks %result.wo
return %result
}
else { return %duration }
}
}
odd (or even)
/isodd {
if ($right($1,1) isin 02468) { return $false }
else { return $true }
}
Read in an html file and display document structure by headers. XHTML 2.0 deprecates the h tags (favoring them for section tags), but here we go anyway.
/outline {
var %f = somefile.html
var %lines = $lines(%f)
var %l = 1
while (%l <= %lines) {
var %line = $read(%f,%l)
if (<h1 isin %line) { echo -s %line }
if (<h2 isin %line) { echo -s - $+ %line }
if (<h3 isin %line) { echo -s -- $+ %line }
if (<h4 isin %line) { echo -s --- $+ %line }
if (<h5 isin %line) { echo -s ---- $+ %line }
if (<h6 isin %line) { echo -s ----- $+ %line }
inc %l
}
}
returns what Nth window the given window name is.
e.g.
$windowID(#test)
alias windowID {
var %windowname = $1
var %numwindows = $window(*,0)
var %x = 1
while (%x <= %numwindows) {
var %curwindow = $window(*,%x)
if (%curwindow == %windowname) { return %x }
inc %x
}
return -1
}
Input length warning. mIRC allows you to type way more text than some servers support.
This alias should be run on a (millisecond) timer.
%maxlen holds the maximum length.
The script will pop up a small flashing custom window which disappears when the length is okay again.
Probably better to capture the string with on:input and split it up into allowed ranges, but anyway.
alias inputLenWarning {
var %text = $editbox($active) | var %active = $active
var %maxlen = 450
if ($calc($len(%text) + $len($active) - $iif($active ischan,1,0)) > %maxlen) {
if ($window(@ILW) == $null) {
set %inputLenWarning 0
if ($active != $window(*,1)) { window -dhloC +bL @ILW -1 -1 190 16 | window -a %active }
}
if ($active != $window(*,1)) { rline %inputLenWarning @ILW 1 WARNING! LINE TOO LONG! }
inc %inputLenWarning | if (%inputLenWarning > 15) { set %inputLenWarning 0 }
beep
}
else { unset %inputLenWarning | window -c @ILW
}
:_end
}
celsius to fahrenheit
alias c2f {
var %f = $round($calc($1 * 9 / 5 + 32),2)
if ($isid == $true) { return $1 $+ °C ( $+ %f $+ °F) }
else { say $1 $+ °C is %f $+ °F }
}
and back
alias f2c {
var %c = $round($calc(($1 - 32) * 5 / 9),2)
if ($isid == $true) { return $1 $+ °F ( $+ %c $+ °C) }
else { say $1 $+ °F is %c $+ °C }
}
backlog - press function key to go back up the log.
Useful if you /cleared a window -just- after somebody said something, and you want to find out what they said.
Repeated pressing moves further back through the log
alias f5 {
if (%backlog == $null) { set -u5 %backlog 0 }
.echo -an BL: $+ $read($window($active).logfile,$calc($lines($window($active).logfile) - %backlog - %backlog))
inc -u5 %backlog
}