mIRC Home    About    Download    Register    News    Help

Print Thread
#181798 31/07/07 08:39 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I trying to change how the text show on input, how ever i cant solve one problem, the code make me flood out, and i cant spot where the problem is, someone that can spot it and explain why it floods me out? tryed to comment the part in the script that maybe needs to be explained. maybe someone can explain how to make the code smaller and more clean?

I have been trying to use echo to see the problem, but i couldent spot it.
Code:
on *:input:*: {
  if ($ctrlenter) || ($left($1,1) === $readini($mircini,text,commandchar) { return }
  if ($active = Status Window) || (@ iswm $active) || (!$1) { echo -s You cant type in the status window. | halt }
  haltdef

  ; change the output if the text contain a url
  var %line = $urlc($1-)

  ; if %ncc = 2 I complete the part off a nick given if it's on the channel
  if (%ncc = 2) || ($left($1,1) == :) {
    set %tline $2-
    set %nick $nick(#,$fline(#,$replace($1,%nctr,*),1,1))
    if (%nick !ison $active) { .msg $target $1- }
    set %tline %nick $+ %owcr $2-
    if (%nick == $null) { goto msg }
    elseif (%nick != $null) { goto msg2 }
    :msg
    if (%sbrackets == close) { echo $theme_color(owntext) -at $theme_nickc($nick) %line }
    if (%sbrackets != close) { echo $theme_color(owntext) -at $theme_nick($nick) %line }
    return
    :msg2
    if (%sbrackets == close) { echo $color(own text) -at $theme_nickc($nick) %nick $+ %ncchr $2- }
    if (%sbrackets != close) { echo $color(own text) -at $theme_nick($nick) %nick $+ %ncchr $2- }
    .msg $target %nick $+ %nctr $2-
  }
}

%sbrackets change the output of the brackets for my self.

if (%sbrackets == close <nick> text
if (%sbrackets != close) < nick > text


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #181803 31/07/07 10:31 AM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
This line:
Code:
if ($ctrlenter) || ($left($1,1) === $readini($mircini,text,commandchar) { return }


Should be:
Code:
if ($ctrlenter) || ($left($1,1) === $readini($mircini,text,commandchar)) { return }

sparta #181811 31/07/07 02:22 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
What is all this about?

Code:
if (%nick == $null) { goto msg }
    elseif (%nick != $null) { goto msg2 }
    :msg
    if (%sbrackets == close) { echo $theme_color(owntext) -at $theme_nickc($nick) %line }
    if (%sbrackets != close) { echo $theme_color(owntext) -at $theme_nick($nick) %line }
    return
    :msg2
    if (%sbrackets == close) { echo $color(own text) -at $theme_nickc($nick) %nick $+ %ncchr $2- }
    if (%sbrackets != close) { echo $color(own text) -at $theme_nick($nick) %nick $+ %ncchr $2- }
    .msg $target %nick $+ %nctr $2-


That's an awful way of doing this:

Code:
if (%nick == $null) { echo $theme_color(owntext) -at $iif(%sbrackets == close,$theme_nickc($nick),$theme_nick($nick)) %line }
else {
  echo $color(own text) -at $iif(%sbrackets == close,$theme_nickc($nick),$theme_nick($nick)) %nick $+ %ncchr $2- 
  .msg $target %nick $+ %nctr $2-
}


Remember that:

Code:
if (x == y) {  }
elseif (x != y) { }


Can always be shortened to:

Code:
if (x == y) {  }
else {  }


Link Copied to Clipboard