All pastes #585759 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-23 12:52 UTC
rendered paste body
; BUSHTARION HELP : Use /bushhelp to turn it on/off.

; Allow people to trigger the script.

on 1:INPUT:*: {
  if (($left($1-, 1) == <) && ($len($1-) != 1)) {
    bushhelp.parse 0 $1-
    /halt
  }
  if ((%g_bushhelp) && ($left($1-, 1) == >) && ($len($1-) != 1)) {
    bushhelp.parse 1 $1-
    /halt
  }
  if (%g_F9 && $left($$1-, 1) != / ) {
    var %text = $1-
    ; To copy/paste incomings.
    if ( *[*]*[*]*Attacking* iswm %text ) { %text = 5 $+ %text $+  }
    if ( *[*]*[*]*Defending* iswm %text ) { %text = 3 $+ %text $+  }
    if ( *[*]*Unknown* iswm %text ) { %text = 10 $+ %text $+  }
    if ( Total:* iswm %text ) { %text = 2 $+ %text $+  }

    ; To copy/paste battle reports.
    if ( *allied*hostile* iswm %text ) || ( *allied*stole* iswm %text ) || ( You gained* iswm %text ) || ( You stole isin %text ) { %text = 3 $+ %text $+  }
    if ( *hostile*allied* iswm %text ) || ( *hostile*stole* iswm %text ) || ( You lost* iswm %text ) { %text = 5 $+ %text $+  }
    if ( Distracted:* iswm %text ) || ( Disabled:* iswm %text ) || ( Bribed:* iswm %text ) || ( Dead:* iswm %text ) { %text = 2 $+ %text $+  }

    ; To display the text if non empty.
    if (%text) { /say %text }
    /halt
  }
}

on 1:NOTICE:*:*: {
  if (((%g_bushhelp) || ($nick == $me)) && ($left($1-, 1) == >) && ($len($1-) != 1)) {
    bushhelp.parse 2 $1-
  }
}

on 1:TEXT:*:#PSA: {
  if ((%g_bushhelp) && ($left($1-, 1) == >) && ($len($1-) != 1)) {
    bushhelp.parse 3 $1-
  }
}

on 1:TEXT:*:?: {
  if ((%g_bushhelp) && ($left($1-, 1) == >) && ($len($1-) != 1)) {
    if ($nick == $me) { bushhelp.parse 4 $1- }
    else { bushhelp.parse 5 $1- }
  }
}

; Private script.
alias -l bushhelp.display {

  var %line, %tok, %limit = 5, %list = $1
  var %i = 0, %m = $numtok(%list, 95) , %n

  if (($2 != 0) && (%m > %limit)) {
    %n = %limit + 1
    %list = $instok(%list, 0, %n, 95)
  }
  else { %n = %m }

  while (%i < %n) {
    inc %i
    %tok = $gettok(%list, %i, 95)

    if (%tok == -1) { /break }
    elseif (%tok == 0) {
      %line = Only first %limit results displayed out of %m $+ .
    }
    else { %line = $read(BushtarionUnits.txt, %tok) }

    if (2 // %i) {
      %line = 10 $+ %line $+ 
    }
    else { %line = 2 $+ %line $+  }

    if ($2 == 0) { echo -a %line }
    elseif ($2 == 1) { say %line }
    elseif ($2 == 2) { .a $nick %line }
    elseif ($2 == 3) { msg $chan %line }
    elseif ($2 == 4) { msg $target %line }
    else { msg $nick %line }
  }
}

; Private script.
alias -l bushhelp.parse {

  if ($1 == 0) {
    var %i = 0, %n = $numtok($2-, 60), %res
    while (%i < %n) {
      inc %i
      bushhelp.seek < $+ $gettok($2-, %i, 60)
      %res = $addtok(%res, $result, 95)
    }
  }
  else {
    var %i = 0, %n = $numtok($2-, 62), %res
    while (%i < %n) {
      inc %i
      bushhelp.seek > $+ $gettok($2-, %i, 62)
      %res = $addtok(%res, $result, 95)
    }
  }
  if (%res == $null) { %res = -1 }
  bushhelp.display %res $1
}

; Private script.
alias -l bushhelp.seek {

  var %seek = $right($1-, -1) $+ *, %found = 0 
  var %line = 0, %temp, %res
  while (%line != 1) {
    %temp = $read(BushtarionUnits.txt, twpn, %seek, %line )
    %line = $readn
    if (%line == 0) { /break }
    %res = $addtok(%res, %line, 95)
    inc %line
    inc %found
  }
  /return %res
}

; Turn the script on/off.
alias bushhelp {
  if (!%g_bushhelp) { %g_bushhelp = 0 }
  %g_bushhelp = $not(%g_bushhelp)
  switch %g_bushhelp Bushtarion Help
}

; Turn the script on/off.
alias F9 {
  if (!%g_F9) { %g_F9 = 0 }
  %g_F9 = $not(%g_F9)
  switch %g_F9 Bushtarion Coloured Reports
}
;____________________________________________________________

alias mass+ {
  .massop
  .massvoice
}

alias mass- {
  .massdeop
  .massdevoice
}

alias massop {

  if ($1) { var %chan = $1 } | else { var %chan = $active }
  var %total = $nick(%chan,0,a,o), %i = 1
  while (%i <= %total) {
    var %nicks = %nicks $nick(%chan,%i,a,o)
    if ($numtok(%nicks,32) == 6) {
      mode %chan +oooooo %nicks
      unset %nicks
    }
    inc %i
  }
  if (%nicks) { mode %chan +oooooo %nicks }
}

alias massdeop {

  if ($1) { var %chan = $1 } | else { var %chan = $active }
  var %total = $nick(%chan,0,o),%i = 1
  while (%i <= %total) {
    if ($nick(%chan,%i,o) != $me) {
      var %nicks = %nicks $nick(%chan,%i,o)
      if ($numtok(%nicks,32) == 6) {
        mode %chan -oooooo %nicks
        unset %nicks
      }
    }
    inc %i
  }
  if (%nicks) { mode %chan -oooooo %nicks }
}

alias massvoice {

  if ($1) { var %chan = $1 } | else { var %chan = $active }
  var %total = $nick(%chan,0,a,v), %i = 1
  while (%i <= %total) {
    var %nicks = %nicks $nick(%chan,%i,a,v)
    if ($numtok(%nicks,32) == 6) {
      mode %chan +vvvvvv %nicks
      unset %nicks
    }
    inc %i
  }
  if (%nicks) { mode %chan +vvvvvv %nicks }
}

alias massdevoice {

  if ($1) { var %chan = $1 } | else { var %chan = $active }
  var %total = $nick(%chan,0,v),%i = 1
  while (%i <= %total) {
    if ($nick(%chan,%i,v) != $me) {
      var %nicks = %nicks $nick(%chan,%i,v)
      if ($numtok(%nicks,32) == 6) {
        mode %chan -vvvvvv %nicks
        unset %nicks
      }
    }
    inc %i
  }
  if (%nicks) { mode %chan -vvvvvv %nicks }
}