All pastes #1514822 Raw Edit

RSPlookup

public text v1 · immutable
#1514822 ·published 2009-08-01 14:05 UTC
rendered paste body
on *:KEYDOWN:@RSP.lookup:*: {
  if ($keyval == 13) { RSP.get.stats %RSL.writer | drawpic -s @RSP.lookup 337 565 150 30 $RSP(Search_down1) }
  else {
    if ($keyval == 8) {
      set %RSL.writer $left(%RSL.writer, -1)
      RSL.update
    }
    else {
      set %RSL.writer %RSL.writer $+ $iif($keyval == 32, $chr(95), $keychar)
      RSL.update
    }
  }
}
Menu channel {
  Project RS
  .Open: /RSP.lookup
}
Menu @RSP.lookup {
  mouse: {
    if (%RSP.stats.drag) {
      window -pdBk0 +d @RSP.lookup $calc($mouse.dx - $gettok(%RSP.stats.drag, 1, 32)) $calc($mouse.dy - $gettok(%RSP.stats.drag, 2, 32))
    }
    if ($mouse.x > 475) && ($mouse.y > 9) && ($mouse.x < 491) && ($mouse.y < 25) {      drawpic -sc @RSP.lookup 475 9 16 16 $RSP(X_pressed)  }
    else { drawpic -sc @RSP.lookup 475 9 16 16 $RSP(X_unpress)    }
    if ($mouse.x > 337) && ($mouse.x < 487) && ($mouse.y > 565) && ($mouse.y < 595) {   drawpic -s @RSP.lookup 337 565 150 30 $RSP(Search_down1) }
    else { drawpic -s @RSP.lookup 337 565 150 30 $RSP(Search_up1) }
  }
  sclick: {
    if ($mouse.x > 475) && ($mouse.y > 9) && ($mouse.x < 491) && ($mouse.y < 25) {
      window -c @RSP.lookup
      .timerRSPunset 5 5 /unset RSP.* | /unset RSL.* | /echo Unsetting RSP variables
    }
    if ($mouse.x > 337) && ($mouse.x < 487) && ($mouse.y > 565) && ($mouse.y < 595) {
      RSP.get.stats %RSL.writer
    }
    if ($mouse.y < 58) {
      set %RSP.stats.drag $mouse.x $mouse.y
    }
  }
  uclick: {
    unset %RSP.stats.drag
  }
  leave: {
    unset %RSP.stats.drag
  }
}
on *:CLOSE:@RSP.lookup: {
  unset RSL.*
}

alias RSL.update {  
  drawpic -cs @RSP.lookup 125 570 200 20 $RSP(Bar1)
  drawtext -p @RSP.lookup 0 Arial 14 135 572 $replace(%RSL.writer, $chr(95), $chr(32)) $+ 1 $+ $chr(124)
}
alias RSP.get.stats {
  if ($1-) {
    RSP.draw.main
    RSL.update
    set %RSP.nick $replace($1- , $chr(32), $chr(43), $chr(95), $chr(43))
    set %RSP.x 0
    set %RSP.y 1
    set %RSP.404 NO
    sockopen RSP.stats hiscore.runescape.com 80
  }
  else {
    RSP.stats.NF $1-
  }
}

on *:SOCKOPEN:RSP.stats: {
  remini $+( $mircdir , ProjectRS\ , RSPML.ini) INFO
  remini $+( $mircdir , ProjectRS\ , RSPML.ini) RANK
  remini $+( $mircdir , ProjectRS\ , RSPML.ini) SCORE
  remini $+( $mircdir , ProjectRS\ , RSPSL.ini) RANK
  remini $+( $mircdir , ProjectRS\ , RSPSL.ini) LEVEL
  remini $+( $mircdir , ProjectRS\ , RSPSL.ini) EXP
  sockwrite -n $sockname GET /index_lite.ws?player= $+ %RSP.nick HTTP/1.1
  sockwrite -n $sockname Host: hiscore.runescape.com $+ $crlf $+ $crlf
  writeini $+( $mircdir , ProjectRS\ , RSPML.ini) INFO NAME %RSP.nick
}
on *:SOCKREAD:RSP.stats: {
  if ($sockerr) {
    Echo -a Error in RSP.stats socket
    halt
  }
  else {
    var %RSP.stats.read
    sockread %RSP.stats.read
    if (HTTP/1.1 404 Not found iswm %RSP.stats.read) {
      RSP.stats.NF %RSP.nick
      set %RSP.404 YES
      sockclose $sockname
    }
    elseif (*,*,* iswm %RSP.stats.read) {
      writeini $+( $mircdir , ProjectRS\ , RSPSL.ini) RANK $RS.skill(%RSP.x) $gettok( $replace(%RSP.stats.read, $chr(44), $chr(95)), 1, 95) 
      writeini $+( $mircdir , ProjectRS\ , RSPSL.ini) LEVEL $RS.skill(%RSP.x) $gettok( $replace(%RSP.stats.read, $chr(44), $chr(95)), 2, 95) 
      writeini $+( $mircdir , ProjectRS\ , RSPSL.ini) EXP $RS.skill(%RSP.x) $gettok( $replace(%RSP.stats.read, $chr(44), $chr(95)), 3, 95)
      inc %RSP.x 1 
    }
    elseif (*,* iswm %RSP.stats.read) && (%RSP.x > 20) {
      writeini $+( $mircdir , ProjectRS\ , RSPML.ini) RANK $RS.Mgame(%RSP.y) $gettok( $replace(%RSP.stats.read, $chr(44), $chr(95)), 1, 95)
      writeini $+( $mircdir , ProjectRS\ , RSPML.ini) SCORE $RS.Mgame(%RSP.y) $gettok( $replace(%RSP.stats.read, $chr(44), $chr(95)), 2, 95)
      inc %RSP.y 1
    }
  }
}
on *:SOCKCLOSE:RSP.stats: {
  if ($window(@RSP.lookup)) {
    unset %RSP.*
    $iif(%RSP.404 == YES, noop, RSP.stats.draw)
  }
  else {
    echo -s Can't find RSP window, don't use these commands without the client.
  }
}
alias RSP.stats.draw {
  set %RSP.draw 0
  drawtext -r @RSP.lookup $rgb(255,255,255) Arial 26 $calc(315 - ($width($RSPML(INFO, NAME), Arial, 26) / 2)) 5 $replace($RSPML(INFO, NAME), $chr(43), $chr(32))
  while (%RSP.draw < 25) {
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 $calc(160 - ($width($RSPSL(RANK, %RS.skill(%RSP.draw)), Arial, 18) / 2)) $calc(60 + (%RSP.draw * 20)) $replace($bytes($RSPSL(RANK, $RS.skill(%RSP.draw)),bd), -1, $chr(45))
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 $calc(270 - ($width($RSPSL(RANK, %RS.skill(%RSP.draw)), Arial, 18) / 2)) $calc(60 + (%RSP.draw * 20)) $replace($bytes($RSPSL(LEVEL, $RS.skill(%RSP.draw)),bd), -1, $chr(45))
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 $calc(370 - ($width($RSPSL(RANK, %RS.skill(%RSP.draw)), Arial, 18) / 2)) $calc(60 + (%RSP.draw * 20)) $replace($bytes($RSPSL(EXP, $RS.skill(%RSP.draw)),bd), -1, $chr(45))
    inc %RSP.draw 1
  }
}
alias RSPSL {
  return $readini( $+($mircdir, ProjectRS\ , RSPSL.ini), $1, $2)
}
alias RSPML {
  return $readini( $+($mircdir , ProjectRS\ , RSPML.ini), $1, $2)
}
alias RSP.stats.NF {
  if ($window(@RSP.lookup)) {
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 150 200 " $+ $1 $+ " is not in the highscores.
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 200 220 OR
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 150 240 There are problems with your connection.
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 200 260 OR
    drawtext -r @RSP.lookup $rgb(255,255,255) Arial 14 150 280 There are problems with highscore servers.
  }
  else {
    echo -s Can't find RSP window, don't use these commands without the client.
  }
}
alias RS.Mgame {
  if ($1 == 1) { return Duel }
  if ($1 == 2) { return Bounty }
  if ($1 == 3) { return Rogues }
  if ($1 == 4) { return FoG }
  if ($1 == 5) { return Armies }
}
alias RS.skill {
  if ($1 == 0) { return Overall }
  if ($1 == 1) { return Attack }
  if ($1 == 2) { return Defence }
  if ($1 == 3) { return Strength }
  if ($1 == 4) { return Hitpoints }
  if ($1 == 5) { return Ranged }
  if ($1 == 6) { return Prayer }
  if ($1 == 7) { return Magic }
  if ($1 == 8) { return Cooking }
  if ($1 == 9) { return Woodcutting }
  if ($1 == 10) { return Fletching }
  if ($1 == 11) { return Fishing }
  if ($1 == 12) { return Firemaking }
  if ($1 == 13) { return Crafting }
  if ($1 == 14) { return Smithing }
  if ($1 == 15) { return Mining }
  if ($1 == 16) { return Herblore }
  if ($1 == 17) { return Agility }
  if ($1 == 18) { return Thieving }
  if ($1 == 19) { return Slayer }
  if ($1 == 20) { return Farming }
  if ($1 == 21) { return Runecrafting }
  if ($1 == 22) { return Hunter }
  if ($1 == 23) { return Construction }
  if ($1 == 24) { return Summoning }
}

alias RSP.lookup {
  set %RSL.writer  
  $iif($window(@RSP.lookup), noop, window -pdBCk0 +d @RSP.lookup 0 0 500 600)
  RSP.draw.main
  RSL.update
}

alias RSP {
  return $mircdir $+ ProjectRS\ $+ $1 $+ .png
}

alias RSP.draw.main {
  drawpic -cs @RSP.lookup 0 0 500 600 $RSP(back2)
  ;;; Drawpictures start
  drawpic -sn @RSP.lookup 475 9 16 16 $RSP(X_unpress)
  drawpic -sn @RSP.lookup 125 570 200 20 $RSP(Bar1)
  drawpic -sn @RSP.lookup 337 565 150 30 $RSP(Search_up1)
  drawpic -stn @RSP.lookup $rgb(255,255,255) 12 12 25 25 $RSP(skill_icon_overall1)
  set %RSP.draw.icons 0
  while (%RSP.draw.icons < 25) {
    drawpic -nst @RSP.lookup $rgb(255,255,255) 12 $calc(60 + (20 * %RSP.draw.icons)) 16 16 $RSP(skill_icon_ $+ $RS.skill(%RSP.draw.icons) $+ 1)
    inc %RSP.draw.icons 1
    drawdot @RSP.lookup
    if (%RSP.draw.icons == 25) {
      unset RSP.draw*
    }
  }

  ;;; Drawpictures end

  ;;; drawlines start
  drawline -r @RSP.lookup $rgb(110,89,49) 1 0 58 500 58 
  drawline -r @RSP.lookup $rgb(110,89,49) 1 130 0 130 58
  drawline -r @RSP.lookup $rgb(110,89,49) 1 130 33 500 33
  drawline -r @RSP.lookup $rgb(110,89,49) 1 0 78 500 78

  ;;; drawlines end

  ;;; drawtext version start
  drawtext -rc @RSP.lookup $rgb(110,89,49) Arial 14 50 10 110 20 RS Lookup
  drawtext -rc @RSP.lookup $rgb(110,89,49) Arial 14 70 30 90 20 v1.0
  ;;; drawtext version end

  ;;; Drawtext categories start
  drawtext -rc @RSP.lookup $rgb(255,255,255) Arial 14 160 38 100 20 Rank
  drawtext -rc @RSP.lookup $rgb(255,255,255) Arial 14 260 38 100 20 Level
  drawtext -rc @RSP.lookup $rgb(255,255,255) Arial 14 360 38 140 20 Experience
  ;;; Drawtext categories end

  ;;; Drawtext skill start
  set %RSP.draw.skills 0
  while (%RSP.draw.skills < 25) {
    drawtext -rc @RSP.lookup $rgb(255,255,255) Arial 14 30 $calc(60 + (20 * %RSP.draw.skills)) 200 16 $RS.skill(%RSP.draw.skills)
    inc %RSP.draw.skills 1
  }

  ;;; drawtext skill end


  ;;;;; $rgb(110,89,49)
  ;;;;; $rgb(94,76,43)
  ;;;;; $rgb(94,66,22)
}