Peace & Protection 4.00 — File Browser

PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / ADDON320.MRC

ADDON320.MRC — 6.73 KB — Download this file

; #= P&P.opt -rs
; ########################################
; Peace & Protection
; PnP 3.20 addon compatibility / support
; ########################################

; $identifiers used by 3.20 addons or listed in 3.20 help
alias _tf2yn return $iif($1,Yes,No)
alias _ccdef return $1- $+ 
alias _i return $calc($1 + 1)
alias _j return $calc($1 - 1)
alias _vi inc % $+ $1 | return % [ $+ [ $1 ] ]
alias _vd dec % $+ $1 | return % [ $+ [ $1 ] ]
alias _lchop return $left($2-,$calc(- $1))
alias _rchop return $right($2-,$calc(- $1))
alias _lpad var %lpad = $str($2,$1) $+ $3- | return $right(%lpad,$calc($1 + $len($3-) - $len($strip($3-))))
alias _rpad var %rpad = $3- $+ $str($2,$1) | return $left(%rpad,$calc($1 + $len($3-) - $len($strip($3-))))
alias _col2text {
  var %text,%fore,%color = $remove($1,,,,)
  if (%color != $null) %fore = $calc($gettok(%color,1,44) % 16 + 1)
  if (, isin %color) var %back = $calc($gettok(%color,2,44) % 16 + 1)
  else var %back = $colour(back)
  if ( isin $1) %text = old
  if ( isin $1) %text = %text underline
  if ( isin $1) %text = %text reverse
  elseif (%fore != $null) {
    %text = %text $gettok(white-black-dark blue-green-red-brown-purple-orange-yellow-lime-aqua-cyan-light blue-pink-dark grey-light grey,%fore,45)
    if (%back != $colour(back)) %text = %text on $gettok(white-black-dark blue-green-red-brown-purple-orange-yellow-lime-aqua-cyan-light blue-pink-dark grey-light grey,%back,45)
  }
  if (%text == $null) return none
  return %text
}
alias _getnicks {
  if ($2 == $null) var %mask = *
  else var %mask = $2
  var %find,%nick,%num = $ialchan(%mask,$1,0)
  if (%num == 0) return
  :loop1
  %nick = $ialchan(%mask,$1,%num).nick
  if (((+o !isin $3) && (-o !isin $3)) || ((%nick isop $1) && (+o isin $3)) || ((%nick !isop $1) && (-o isin $3)) ) %find = %find %nick
  if (%num > 1) { dec %num | goto loop1 }
  if (not isin $3) %find = $remtok(%find,$me,1,32)
  if (xw isin $3) {
    %num = 1
    :loop2
    if ($gettok(%!servnick,%num,32)) { %find = $remtok(%find,$ifmatch,1,32) | inc %num | goto loop2 }
  }
  return %find
}
alias _getchans {
  var %find,%num = $chan(0)
  :loop
  if (%num) {
    %find = %find $chan(%num)
    dec %num | goto loop
  }
  return %find
}
alias _keys return $_s2c($_cfgx(key,$1))
alias _getmsg return $_msg($2)
alias _nickcomp return $_ncc($1,$2)
alias _nickglob return $_nc($1)
alias _nickcseries return $_nccs($1,$2,$3)
alias _nickseries return $_ncs($1,$2)
alias _stripc return $strip($1-,c)
alias _ppcfg return $_cfgx($1,$2)
alias _numtok return $numtok($2-,$1)
alias _if if ($4 != $null) return $_if2($1-) | if ($1 $2 $3) return $true | return $false
alias _if2 if (& isin $4) { if (($1 $2 $3) && ($5 $6 $7)) return $true | return $false } | if (($1 $2 $3) || ($5 $6 $7)) return $true | return $false
alias _ifn if ($1 == $null) return null | return $1
alias _iniprep if ($1 == $null) return | return $replace($1-,[,$chr(40),],$chr(41),=,-,$chr(32),_)
alias _ppdir if ($chr(32) isin $mircdir) return config\ $+ %!user $+ \ | else return $mircdirconfig\ $+ %!user $+ \
alias _mircdir if ($chr(32) isin $mircdir) return | else return $mircdir
alias _a2x if ($1 == $null) return | return $replace($1-,&,&&)
alias _pwenc return $_pw.enc($1-)
alias _ltok if ($1 == 0) return | return $gettok($3-,1- [ $+ [ $1 ] ] ,$2)
alias _rtok if ($1 == 0) return | if ($calc($gettok($3-,0,$2) - $1 + 1) < 1) return $3- | return $gettok($3-, [ [ $calc($gettok($3-,0,$2) - $1 + 1) ] $+ ] - ,$2)
alias _tf2any if ($1) return $_p2s($2) | return $_p2s($3-)
alias _plural if ($2 == 1) return $1 | return $1 $+ s
alias _plural2 if ($3 == 1) return $1 | return $2
alias _color return  $+ $colour($1)

; /aliases used by 3.20 addons or listed in 3.20 help
alias _timersinc inc -u $+ $1 % $+ $2 $3
alias _massmode {
  _init.mass $1 | var %num = 3
  :loop
  if ($ [ $+ [ %num ] ] != $null) {
    _add.mass $iif(- isin $2,-,+) $remove($2,+,-) $ifmatch
    inc %num | goto loop
  }
}
alias _pentry _juryrig2 _pentry2 $1- | halt
alias _pentry2 {
  var %opt1 = (Enter for default, ESC to cancel),%opt2 = (Enter for none, ESC to cancel)
  $gettok($1,1,127) $_entry($iif($right($1,1) == ,0,1),$gettok($1,2-,127),$replace($2-,1,%opt1,2,%opt2))
}
alias _askr _pentry $1 $+  $2- $+ (ESC or Enter to cancel)
alias _askyn _juryrig2 _askyn2 $1-
alias _askyn2 if ($_okcancel(1,$2-)) $1
alias _arhelp %_arhelp $1- | unset %_arhelp
alias _lookup {
  _Q.userhost _lookup2&n!&a $+ $_s2p($2-) _lookup3 $+ $1 $1
  dispa Looking up address of $:t($1) $+ ...
  halt
}
alias _lookup2 {
  if ($2 isnum) var %mask = $_ppmask($1,$2)
  elseif ($2 == *) var %mask = $mask($1,3)
  else var %mask = $1
  $reptok($3-,$chr(44),%mask,1,32)
}
alias _lookup3 dispa Address search failed- No such user $:t($1)
alias _writecfg _cfgxw $1-
alias _exec $1- | return
alias _dynpop.rot {
  window -hl @.recent
  var %rec2f = $_cfg($1.rct),%num = 2
  aline @.recent $3-
  if ($exists(%rec2f)) loadbuf @.recent %rec2f
  %^ [ $+ [ $1. ] $+ [ 1 ] ] = $3-
  :loop
  if ($line(@.recent,%num) != $3-) { %^ [ $+ [ $1. ] $+ [ %num ] ] = $ifmatch | inc %num }
  else dline @.recent %num
  if ((%num <= $2) && (%num <= $line(@.recent,0))) goto loop
  savebuf 1- $+ $2 @.recent %rec2f
  window -c @.recent
  %^ [ $+ [ $1.clear ] ] = Clear this list
}
alias _timer924on _tut.on
alias _timer924off return

; Event halting interfaces (from 3.20 help)
ctcp &*:*:if ((%.+disphalt) || (%.+ctcpprochalt)) { unset %.+ctcpprochalt %.+disphalt | halt }
on &*:CTCPREPLY:*:if (%.+disphalt) { unset %.+disphalt | halt }
#_rawhalts off
raw &*:*:.timer -om 1 0 .disable #_rawhalts | halt
#_rawhalts end
#_inputhalt off
on &*:INPUT:*:unset %.input.type | .timer -om 1 0 .disable #_inputhalt
#_inputhalt end

; Color variables and other variables
on *:CONNECT:%pp.net = %!net
on *:DISCONNECT:.timer 1 0 %pp.net = Offline
alias _pnp320compat {
  window -hl @.markup
  loadbuf 1-22 @.markup $_cfg(display.dat)
  %col.base = $_cprep($line(@.markup,3))
  %col.dark =  $+ $_cprep($line(@.markup,4))
  %col.target =  $+ $_cprep($line(@.markup,4)) $+ $+ $line(@.markup,8)
  %col.att =  $+ $_cprep($line(@.markup,6))
  %col.info1 =  $+ $_cprep($line(@.markup,5))
  %col.info2 =  $+ $_cprep($line(@.markup,5))
  %col.info3 =  $+ $_cprep($line(@.markup,5))
  %col.whois =  $+ $_cprep($line(@.markup,5))
  %col.option =  $+ $_cprep($line(@.markup,4))
  %col.misc =  $+ $_cprep($line(@.markup,5))
  %col.addr =  $+ $_cprep($line(@.markup,4))
  %col.serv =  $+ $_cprep($colour(norm))
  %col.cust = -c $+ $line(@.markup,3)
  %col.cdark = -c $+ $line(@.markup,4)
  window -c @.markup
  %pp.ver = $:ver
  %= = $:::
  %font.fixtab = 20
  ; %font.basic and %font.quick left null on purpose, to open windows w/status font
}