mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Changing my own text output #210691 23/03/09 09:36 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
I'm fairly certain this can't be done, but is there a way to halt what I've typed into a chat window so I can replace what I see with something else? To clarify, I have an alias that changes what I type into something else, and I would like to hide that "something else" that is sent to the channel via a /msg command, and replace it with the original message.

Re: Changing my own text output [Re: KageNoOni] #210697 23/03/09 10:47 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Code:
on ^*:text:*:#: {
  haltdef
  echo -a $1-
}
on ^*:text:*:?: {
  haltdef
  echo -a $1-
}
on *:input:*: {
  if ($left($1,1) == $readini(mirc.ini,text,commandchar)) && (!$ctrlenter) { return }
  .msg $target $1- 
  echo -a $1-
}

Wanted to add:

the . infront of msg will stop the message to be shown to you.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: Changing my own text output [Re: sparta] #210708 23/03/09 06:02 PM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
If .msg will hide it, all I need to do is add that to my existing alias. Will that automatically hide it, or is that based on something else in there whose function I don't understand? ($left and $target) Also, I notice you put it in the on input part, so is that necessary to stop what would normally display? Anyway, I'll be checking the help files for more info regarding the $left and $target commands, thanks for the help so far.

Edit: Just tested the .msg part alone, I stuck it in my alias and it did the trick. Thanks for the help.

One more thing, according to the help files your own messages to a channel or query can't trigger an on text event, yet the suggestions you've made look like they are intended to trigger on my own messages to a channel, is there an exception for the ^ prefix events?

Last edited by KageNoOni; 23/03/09 06:35 PM.
Re: Changing my own text output [Re: KageNoOni] #210713 23/03/09 07:58 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
if ($left($1,1) == $readini(mirc.ini,text,commandchar)) && (!$ctrlenter)

That line read mirc.ini, then check what command char you have. (default is /), if the first letter you type is /, then that reurn true, and it then check so you don't have CTRL pressed, if you have the command will be sent to the channel. /say hi (if not CTRL is pressed) will send the message "hi" to the channel, press down CTRL and the whole line will be sent with the /say hi and everything.. $target = the active window..

;--------- Edit

on ^*:text:*:#:

will react on text typed by someone else, not by you..

Last edited by sparta; 23/03/09 07:59 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: Changing my own text output [Re: sparta] #210718 23/03/09 10:34 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
/ is always a command character. The one stored at $readini(mirc.ini,text,commandchar) is an additional command character, so you should check for both:

Code:
if ($left($1,1) isin / $readini($mircini,text,commandchar)) && (!$ctrlenter)


I've also changed mirc.ini to $mircini because the mirc.ini file isn't always in the mIRC directory.

Re: Changing my own text output [Re: KageNoOni] #210720 23/03/09 10:58 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline
Babel fish
Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Here is a snippet of the code I'm using to do that for me, you can probably modify it to suit your needs or get one of the guys/gals here to help you out with it smile

Code:
;=============================+
; Nickname Identifier Changer |
;=============================+
alias msg {
  if ($cnick($me)) { var %tri.nickcolour $+(,$cnick($me).color) }
  else { var %tri.nickcolour 3 }
  if ($2 == $chr(160)) { echo -mi2 $1 $+(14,$timestamp) $+(4[,%tri.nickcolour,$me,4]) $chr(160) }
  elseif ($active == Status Window || $1 != $chan && !$query($1) && ($left($1,1) != =) && ($left($alias,1) != .)) {
    echo $timestamp -> $+(*,$1,*) $2-
  } 
  else { echo -mi2 $1 $+(14,$timestamp) $+(4[,%tri.nickcolour,$me,4]) $2- }
  .msg $1 $2-
  haltdef
}
alias say {
  if ($cnick($me)) { var %tri.nickcolour $+(,$cnick($me).color) }
  else { var %tri.nickcolour 3 }
  if ($1 == $chr(160)) { echo -mi2 $active $+(14,$timestamp) $+(4[,%tri.nickcolour,$me,4]) $chr(160) }
  else { echo -mi2 $active $+(14,$timestamp) $+(4[,%tri.nickcolour,$me,4]) $1- }
  if ($left($1-,1) == :) { .raw privmsg $active $+($chr(58),$1-) }
  else { .raw privmsg $active $1- }
  haltdef
}
alias describe {
  if ($2 == $chr(160)) { echo 12 -mi2 $active $+(14,$timestamp,) • $me $chr(160) }
  else { echo 12 -mi2 $active $+(14,$timestamp,) • $me $2- }
  .describe $active $2-
  haltdef
}
alias me {
  if ($1 == $chr(160)) { echo 12 -mi2 $active $+(14,$timestamp,) • $me $chr(160) }
  else { echo 12 -mi2 $active $+(14,$timestamp,) • $me $1- }
  .me $1-
  haltdef
}
on *:INPUT:*:{
  set %awayvalue 1
  if (%awaynow == on) {
    set %awaynow off
    set %awayvalue 1
    scon -at1 away
  }
  if ($active == Status Window) { return }
  elseif ($left($active,1) == @) { return }
  elseif ($1 == /me) {
    if (!$2) {
      .describe $active $chr(160)
      haltdef
    }
    else {
      .describe $active $2-
      haltdef    
    }
  }
  elseif ($left($1-,1) == /) { return }
  elseif (!$1) {
    .msg $active $chr(160)
    haltdef
  }
  else {
    .msg $active $1-
    haltdef
  }
}
on ^*:TEXT:*:*:{
  if ($cnick($nick)) { var %tri.nickcolour $+(,$cnick($nick).color) }
  else { var %tri.nickcolour 10 }
  var %target = $iif($chan,$chan,$nick)
  echo -mlbfi2 %target $+(14,$timestamp) $+(4[,%tri.nickcolour,$nick,4]) $1-
  haltdef
}
on ^*:ACTION:*:*:{
  var %target = $iif($chan,$chan,$nick)
  echo 12 -mi2lbf %target $+(14,$timestamp,) • $nick $1-
  haltdef
}
on ^*:CHAT:*:{
  if ($cnick($nick)) { var %tri.nickcolour $+(,$cnick($nick).color) }
  else { var %tri.nickcolour 10 }
  var %nickname = $nick
  echo -mi2lbf = $+ %nickname $+(14,$timestamp) $+(4[,%tri.nickcolour,$nick,4]) $1-
  haltdef
}


GigIRC Network Admin
irc.gigirc.com
Re: Changing my own text output [Re: KageNoOni] #210722 23/03/09 11:45 PM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Sparta, I misunderstood the point of that in the script, it's meant to halt the default text for the other person. I was expecting a way to halt only my text, which is why I misunderstood. Also, I know what the !$ctrlenter was for, I know how using Ctrl + Enter makes one send the exact written word instead of executing a command, I had no problem with that part. I've since looked up $left, and understand what it does, it checks the first letter of the first word in that particular use. I didn't know what it was looking for in the mirc.ini file though, thanks for that. Also, I don't really need to check and see if the default is changed for my particular mIRC, I never changed it, and wouldn't want to use another character anyway, / is much easier for me. Didn't know what $target was though, it sounds like it is the same as $active right?

Trixar_za, that script will take me a bit to go through completely, but I see the gist of how it works. You don't seem to have anything for adding a symbol that represents status on a channel though. If I adopt it, I'll probably add that little detail. Got a question about it though. When I try to see what $chr(160) is, I get a blank, no symbol or anything else shows up. What character does that represent? Is it a font code of some kind like 2 and 3?

Also, thanks Hixxy for that detail, but as I mentioned when replying to Sparta, I don't use any other command characters. But the detail about $mircini I'll remember, I may have to look through that file some day, as I've heard a few useful tidbits are in there.

For those of you wanting to know why I was after this, here's the script.

Code:
/encode {
  /var %code $rand(1,25)
  /var %a 1
  /var %string  $+ %code $+ 
  While (%a <= $0) {
    /var %word $gettok($1-,%a,32)
    /var %b 1
    While (%b <= $len(%word)) {
      /var %letter $mid(%word,%b,1)
      if (($asc(%letter) >= 65) && ($asc(%letter) <= 90)) {
        /var %asc $asc(%letter) + %code
        if (%asc > 90) {
          /var %asc %asc - 26
        }
        /var %letter $chr(%asc)
      }
      if (($asc(%letter) >= 97) && ($asc(%letter) <= 122)) {
        /var %asc $asc(%letter) + %code
        if (%asc > 122) {
          /var %asc %asc - 26
        }
        /var %letter $chr(%asc)
      }
      if ((%b == 1) && (%a > 1)) {
        /var %string %string %letter
      }
      if (((%b == 1) && (%a == 1)) || (%b > 1)) {
        /var %string %string $+ %letter
      }
      /var %b %b + 1
    }
    /var %a %a + 1
  }
  /return %string
}
/code {
  /encode $1-
  .msg $active $result
  /echo -a $+($chr(91),$time,$chr(93) <,$me,>) (encoded) $1-
}
/bcode {
  /encode $1-
  /bsay $result
}
/msgcode {
  /encode $2-
  .msg $1 $result
  /echo $1 $+($chr(91),$time,$chr(93) <,$me,>) (encoded) $1-
}

Next the Remote script.
Code:
On ^*:Text:**:*:{
  if (** iswm $1) {
    var %numa $mid($1,3,2)
    var %kba $mid($1,5,2)
    var %numb $mid($1,3,1)
    var %kbb $mid($1,4,2)
    if ((%numa isnum) && (%kba == )) {
      var %code %numa
      var %all $mid($1-,7,$len($1-))
    }
    elseif ((%numb isnum) && (%kbb == )) {
      var %code %numb
      var %all $mid($1-,6,$len($1-))
    }
    var %code 26 - %code
    var %a 1
    While (%a <= $0) {
      var %word $gettok(%all,%a,32)
      var %b 1
      While (%b <= $len(%word)) {
        var %letter $mid(%word,%b,1)
        if (($asc(%letter) >= 65) && ($asc(%letter) <= 90)) {
          var %asc $asc(%letter) + %code
          if (%asc > 90) {
            var %asc %asc - 26
          }
          var %letter $chr(%asc)
        }
        if (($asc(%letter) >= 97) && ($asc(%letter) <= 122)) {
          var %asc $asc(%letter) + %code
          if (%asc > 122) {
            var %asc %asc - 26
          }
          var %letter $chr(%asc)
        }
        if ((%b == 1) && (%a > 1)) {
          var %string %string %letter
        }
        if (((%b == 1) && (%a == 1)) || (%b > 1)) {
          var %string %string $+ %letter
        }
        var %b %b + 1
      }
      var %a %a + 1
    }
    if ($chan != $null) {
      echo $chan $+($chr(91),$time,$chr(93) <,$nick,>) (encoded) %string
    }
    else {
      /echo $nick $+($chr(91),$time,$chr(93) <,$nick,>) (encoded) %string
    }
    haltdef
  }
}


A bit long and drawn out, but it basically messes with the ascii of what I type into a chat, then sends out the encoded message. It also shows what the original message is, and any one else with the same script, can read it, and reply to it, but those with out the script see nothing but nonsense. I did it partly because it's fun getting reactions from people seeing it, and also just to see if I could pull it off. The only thing I had been missing was the .msg part. Thanks Sparta for that, this was exactly what I had been looking for.

Thanks every one for your replies, I've learned a bit today.

Re: Changing my own text output [Re: KageNoOni] #210761 24/03/09 09:47 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline
Babel fish
Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
$chr(160) is normally a blank character on most fonts (not all, for example System shows it as block) - I use it so that I can sent blank lines for pasting text documents with spaces between paragraphs in them and mostly just because other clients could do it (like XChat).

As for the symbol, I would love to be able to to add support for this, but I just couldn't get it to work - maybe somebody here can help me out with that.

btw you don't need this:
Code:
set %awayvalue 1
  if (%awaynow == on) {
    set %awaynow off
    set %awayvalue 1
    scon -at1 away
  }

Because it's part of my auto-away script smile

Last edited by Trixar_za; 24/03/09 09:49 PM.

GigIRC Network Admin
irc.gigirc.com
Re: Changing my own text output [Re: Trixar_za] #210765 25/03/09 02:25 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Yeah, I figured out what that part of the script was for, that wasn't too hard. But I don't really use an auto away myself. Thanks again for the help.

Last edited by KageNoOni; 25/03/09 02:25 AM.
Re: Changing my own text output [Re: KageNoOni] #210770 25/03/09 08:52 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
$chr(160) is called a "hard space", and do almost the same thing as $chr(32) smile with $chr(160) you can force mirc to have more then one space in a text or something like that..
Code:
//echo -a $+(moo,$chr(32),$chr(32),$chr(32),moo) <- still 1 space
//echo -a $+(moo,$chr(160),$chr(160),$chr(160),moo) <- have 3 spaces.



if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: Changing my own text output [Re: sparta] #210782 25/03/09 07:45 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline
Babel fish
Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
True, and you can use it to show variables that might start with a space or many spaces (like in a MUD over a socket for example). This is a nice way to avoid msg and echo errors in that regard smile


GigIRC Network Admin
irc.gigirc.com
Re: Changing my own text output [Re: sparta] #210792 25/03/09 11:32 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
please stop furthering the misconception/myth that $chr(160) is a "space", hard or soft. $chr(160) is a blank glyph on VERY FEW Windows ANSI codepages for VERY FEW fonts. If someone was using the "Terminal" font, for instance, it shows up as another character completely. If you want a real NBSP use the Unicode codepoint U+00A0, aka. $utfencode($chr(160)) (not to be confused with $chr(160))-- of course, this only works with Unicode on and no ANSI codepage usage in the same line.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Changing my own text output [Re: sparta] #210797 26/03/09 01:07 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
Generally when I wanted multiple spaces, I did use $chr(32), but I'd do it with $+($chr(32),$chr(32),$chr(32),$chr(3)) and make sure that I either add nothing after that, or make sure that what I want to add isn't a number. Though one could use 2 $chr(2) back to back for the same purpose. Either way, it ensures the spaces stay, so I can achieve the same result either way.

Argv0, I haven't encountered that $utfencode identifier, I have something else I get to look up, which is great, I'm learning a lot already just on this thread I made to find the .msg method. I hope to learn a great deal more, and I may be making more threads like this in the future.

Edit: Hmm, nothing shows in the help files for that identifier. What does that do exactly?

Last edited by KageNoOni; 26/03/09 01:09 AM.
Re: Changing my own text output [Re: KageNoOni] #210798 26/03/09 01:11 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
It's one of the few undocumented identifiers-- looking at versions.txt usually helps in those situations, but it basically encodes the non-unicode text as utf-8

In the case of encoding $chr(160) as utf-8, I believe it turns into the byte string: $chr(192) $+ $chr(160)

Originally Posted By: versions.txt

48. ...snip...

Added $utfencode(text, C) and $utfdecode(text, C), where C is the
script/codepage ($window().fontcs) of the plain text.

Added $isutf(text) identifier, returns UTF-8 status of text, where
0 = not UTF-8 (contains invalid UTF-8 sequences), 1 = seems to be
plain text, 2 = seems to contain valid UTF-8.


Note the non-unicode way to do spaces is similar to yours, but I use:

Code:
space { return $str($+($chr(22),$chr(32),$chr(22)),$$1) }


$chr(22) is the reverse control code-- as long as you have an even number of them, it should not affect control codes on the rest of the line like ctrl+k would.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Changing my own text output [Re: argv0] #210799 26/03/09 05:38 AM
Joined: Feb 2005
Posts: 342
R
Rand Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
(Not really directed at argv0, just a general reply)

Another option is to use a special DLL called spaces.dll, which will allow you to keep spaces intact. Example:

//var %a = $+(text,$str($chr(32),5),more text) | noop $dll(spaces.dll,echo, -a %a)

Will echo it to your active window with the five spaces between "text" and "more text" intact.

Edit: You can find a copy of spaces.dll on mirc.net
Edit2:
I'm not quite sure what argv0 was attempting to accomplish with $chr(22)/ctrl+r, but I'm thinking perhaps he meant the "bold" control code $chr(2)/ctrl+b. You'd still need an even number of them in order to not mess with any bolding done previously.

The reverse control code will make your space show up as a block with the coloring of whatever you have "Normal Text" set to (in the alt+k color dialog).

Last edited by Rand; 26/03/09 06:08 AM.
Re: Changing my own text output [Re: Rand] #210800 26/03/09 08:16 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
I would prefer the double bold code, already even suggested that, but for the uses I generally choose, there hasn't been an issue where that would remove the color coding. For example, I've got a script that chooses a different color for each letter of each word I type, and adds 3 spaces to either side so that the background color can stretch out a bit on either side. For that one, the Ctrl+K color code works fine as it's done both at the end of the script, and before the coloring of the letters begins, so it doesn't interfere with the part that is intentionally colored.

Re: Changing my own text output [Re: KageNoOni] #210801 26/03/09 08:52 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Using bold becomes an issue (as I've found out personally) because it actually makes the space glyph slightly wider, even under fixed-width fonts, so you would end up with text not properly aligned where it otherwise should be. You should use either underline or reverse codes as shown above, because they don't affect the spacing or size of the whitespace.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Changing my own text output [Re: argv0] #210804 26/03/09 10:31 AM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
That depends on how you do it. I don't put a space between the 2 codes. I do $+($chr(32),$chr(2),$chr(2)) but using as many $chr(32) as I need before doing the double bold code. That one affects nothing, so the variable I am using just adds the appropriate number of spaces, followed by the double bold code, then when it's sent to the server, the 2 codes just cancel each other out. I don't even know why you'd want to put the space between the codes. I was helping some one make a script similar to this one I did above, and used the double bold at the beginning of the line to get the remote to listen for it, and auto translate. Nothing looks different, no spacing changes, or anything like that.

Re: Changing my own text output [Re: argv0] #210805 26/03/09 10:52 AM
Joined: Feb 2005
Posts: 342
R
Rand Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
True, though any other way you'd still pretty much be required to use double control codes, as using reverse or underline will cause just the "space" itself to appear as either an underline on it's own, or a reverse color block.

<u> <u> <u> <u>Text, for example will give you something that looks a lot like: _ _Text.

Though I suppose if you were against using the spaces.dll idea, you could /strip +r, and //echo -r text $chr(2) $chr(2) $chr(2) $chr(2) text, and then you could use single reverse/underline codes.

Re: Changing my own text output [Re: Rand] #210816 26/03/09 05:18 PM
Joined: Mar 2009
Posts: 74
K
KageNoOni Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
And you also stick the spaces between the codes. Why not just do the appropriate number of spaces first and stick the codes after? That was what my example was, as many spaces as needed that ends with a double bold, with nothing between the 2 bold codes. Using that method you do have to use the $chr(32) for each space, but when you do all that, you finish with a $chr(2) $+ $chr(2). Only 2 bold codes total, and the spaces all come before it.

Page 1 of 2 1 2