mIRC Home    About    Download    Register    News    Help

Print Thread
#200396 04/06/08 11:29 PM
Joined: Aug 2006
Posts: 43
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 43
i wrote this code with some help from RusselB a year ago, and am now wondering... is it possible to shrink this down some?

Code:
power {
  var %a = 1, %b = $scon(0)
  var %networks = network $+ $iif(%b > 1,s), %chan = channel
  while %a <= %b  {
    .scon %a
    var %c = 1, %d = $chan(0)
    inc %chans %d
    if %d > 1 || %chan == channels {
      %chan = channels
    }
    %chan = $remove(%chan,$chr(32))
    while %c <= %d {
      inc %noobs $iif($me ison $chan(%c),$nick($chan(%c),0,a,o),$iif($me ishop $chan(%c),$nick($chan(%c),0,a,oh),$nick($chan(%c),0,r)))
      inc %Op $iif($me isop $chan(%c),1,0)
      inc %hop $iif($me ishop $chan(%c),1,0)
      inc %Voice $iif($me isvoice $chan(%c),1,0)
      inc %c
    }
    inc %a
  }
  scon -r
  msg $active  15C14onnected 15H14ere 15V14ia3: 10<12  $+ $server $+  10>14. 15I H14ave: 10<4 $+(%op, $+ 3/04 $+ ,%chans)  10> 15O14ps, 10<4 $+(%hop, $+ 3/04 $+ ,%chans) 10> 15H14elp10-15O14ps 15a14nd 10<4 $+(%voice, $+ 3/04 $+ ,%chans) 10> 15V14oices. 15I A14m 15O14n 10<4 $scon(0) 10> 15N14etwork(s). 15I H14ave 15C14ontrol 15O14ver 10<4 %noobs 10> 15M14ortal 15V14ictoms. $drdev_pwrlogo 7By $drdev_teamlogo
  unset %Op
  unset %hop
  unset %voice
  unset %chans
  unset %noobs
}


Thanks in advance for any help
ps. this goes in aliases

G
genius_at_work
genius_at_work
G
Try this:

Code:

alias power {
  var %an = 0, %ao = 0, %ah = 0, %av = 0, %ch
  var %cs = 0, %n = 0, %nn = $scon(0)
  while (%n < %nn) {
    inc %n
    scon %n

    var %c = 0, %cc = $chan(0)
    while (%c < %cc) {
      inc %c
      inc %cs
      %ch = $chan(%c)

      if ($me isop %ch) inc %an $nick(%ch,0,a,o)
      elseif ($me ishop %ch) inc %an $nick(%ch,0,a,oh)

      if ($me isop %ch) inc %ao
      if ($me ishop %ch) inc %ah
      if ($me isvoice %ch) inc %av
    }
  }
  scon -r

  msg $active $+($_a(Connected Here Via:) $_b($server),$_a(. I Have:) $_c(%ao,%cs) $_a(Ops) $_c(%ah,%cs) $&
    $_a(Help-Ops and) $_c(%av,%cs) $_a(Voices. I Am On) $_c(%nn) $_a(Network $+ $iif(%nn != 1,s) $+ .) $&
    $_a(I Have Control Over) $_c(%an) $_a(Mortal Victims.) $drdev_pwrlogo 7By $drdev_teamlogo)
}
alias _a return $regsubex($1-,/([\s-]|^)([a-z.])/gi,$+(\1,15,\2,14)) $+ 
alias _b return $+(10< 12,$1-, 10>)
alias _c return $+(10< 04,$1,$iif($2 != $null,$+(3/04,$2)), 10>)



It goes in the Remotes section.

-genius_at_work

#200403 05/06/08 02:25 AM
J
Joe_Dean
Joe_Dean
J
lol, the guy asked for a shrinked version, and all you did was rewrite it and made it even longer. XD

#200407 05/06/08 03:05 AM
G
genius_at_work
genius_at_work
G
What I did is improved it, corrected its functionality, and removed redundant/repetitive code.

If you (or the OP) wants it to be physically smaller (fewer lines), remove the blank lines and recondense the lines with $& . Personally, I don't code that way because it is mode difficult to read because lines are all bunched together and some extend beyond the right edge of the script editor.


Code that is smaller, yet functionally the same:

Code:

alias power {
  var %an = 0, %ao = 0, %ah = 0, %av = 0, %ch, %cs = 0, %n = 0, %nn = $scon(0)
  while (%n < %nn) {
    inc %n 
    scon %n
    var %c = 0, %cc = $chan(0), %cs = $calc(%cs + %cc)
    while (%c < %cc) {
      inc %c
      if ($me isop $chan(%c)) inc %an $nick($chan(%c),0,a,o)
      elseif ($me ishop $chan(%c)) inc %an $nick($chan(%c),0,a,oh)
      if ($me isop $chan(%c)) inc %ao
      if ($me ishop $chan(%c)) inc %ah
      if ($me isvoice $chan(%c)) inc %av
    }
  }
  scon -r
  msg $active $+($_a(Connected Here Via:) $_b($server),$_a(. I Have:) $_c(%ao,%cs) $_a(Ops) $_c(%ah,%cs) $_a(Help-Ops and) $_c(%av,%cs) $_a(Voices. I Am On) $_c(%nn) $_a(Network $+ $iif(%nn != 1,s) $+ .) $_a(I Have Control Over) $_c(%an) $_a(Mortal Victims.) $drdev_pwrlogo 7By $drdev_teamlogo)
}
alias _a return $regsubex($1-,/([\s-]|^)([a-z.])/gi,$+(\1,15,\2,14)) $+ 
alias _b return $+(10< 12,$1-, 10>)
alias _c return $+(10< 04,$1,$iif($2 != $null,$+(3/04,$2)), 10>)



-genius_at_work

#200409 05/06/08 04:43 AM
L
Lpfix5
Lpfix5
L
Originally Posted By: genius_at_work
What I did is improved it, corrected its functionality, and removed redundant/repetitive code.

If you (or the OP) wants it to be physically smaller (fewer lines), remove the blank lines and recondense the lines with $& . Personally, I don't code that way because it is mode difficult to read because lines are all bunched together and some extend beyond the right edge of the script editor.


Code that is smaller, yet functionally the same:

Code:

alias power {
  var %an = 0, %ao = 0, %ah = 0, %av = 0, %ch, %cs = 0, %n = 0, %nn = $scon(0)
  while (%n < %nn) {
    inc %n 
    scon %n
    var %c = 0, %cc = $chan(0), %cs = $calc(%cs + %cc)
    while (%c < %cc) {
      inc %c
      if ($me isop $chan(%c)) inc %an $nick($chan(%c),0,a,o)
      elseif ($me ishop $chan(%c)) inc %an $nick($chan(%c),0,a,oh)
      if ($me isop $chan(%c)) inc %ao
      if ($me ishop $chan(%c)) inc %ah
      if ($me isvoice $chan(%c)) inc %av
    }
  }
  scon -r
  msg $active $+($_a(Connected Here Via:) $_b($server),$_a(. I Have:) $_c(%ao,%cs) $_a(Ops) $_c(%ah,%cs) $_a(Help-Ops and) $_c(%av,%cs) $_a(Voices. I Am On) $_c(%nn) $_a(Network $+ $iif(%nn != 1,s) $+ .) $_a(I Have Control Over) $_c(%an) $_a(Mortal Victims.) $drdev_pwrlogo 7By $drdev_teamlogo)
}
alias _a return $regsubex($1-,/([\s-]|^)([a-z.])/gi,$+(\1,15,\2,14)) $+ 
alias _b return $+(10< 12,$1-, 10>)
alias _c return $+(10< 04,$1,$iif($2 != $null,$+(3/04,$2)), 10>)



-genius_at_work


I've been waiting for this day for a very long time. genius_at_work I always read many threads you reply or quote and I happend to notice you never really make mistakes when you (speak) write. However on this particular thread you wrote mode instead of more wink Idk, makes me love the fact that were all humans and we are not all designed to be 100% accurate.

#200410 05/06/08 04:52 AM
Joined: Aug 2006
Posts: 43
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 43
thanks thats perfect

#200435 05/06/08 02:20 PM
G
genius_at_work
genius_at_work
G
That was intentional. :P

-genius_at_work


Link Copied to Clipboard