mIRC Home    About    Download    Register    News    Help

Print Thread
#200396 04/06/08 11:29 PM
Joined: Aug 2006
Posts: 44
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 44
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

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Joined: May 2008
Posts: 127
J
Vogon poet
Offline
Vogon poet
J
Joined: May 2008
Posts: 127
lol, the guy asked for a shrinked version, and all you did was rewrite it and made it even longer. XD

Joe_Dean #200407 05/06/08 03:05 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
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.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2006
Posts: 44
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 44
thanks thats perfect

Lpfix5 #200435 05/06/08 02:20 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
That was intentional. :P

-genius_at_work


Link Copied to Clipboard