mIRC Home    About    Download    Register    News    Help

Print Thread
Question on aline... #174726 11/04/07 08:55 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Well, Basically I wanted to create a script so I can play my favorate MUD, so I found a telnet script and modded it a bit to see if I can get the Mud game to display colour code correctly. It works (it displays correctly), but seems my mod keeps giving me this error :

* /aline: insufficient parameters (line 38, Mudclient.mrc)

Here is the modded code:

Code:
menu channel {
  Telnet
  .Connect:dialog -ma Telnet Telnet
}
dialog telnet {
  title "Telnet"
  size -1 -1 200 135
  edit "mud.wormhole.se", 1, 5 25 190 20, autohs
  text "Port", 2, 6 47 50 20
  edit "4000", 3, 5 65 190 20, autohs
  button "Connect", 4, 5 95 60 30, ok
  button "Cancel", 5, 135 95 60 30, cancel
  box "Remote Host:", 6, 0 1 200 135
}
on *:dialog:telnet:sclick:4: {
  %hd.telnet.addy = $did(1).text
  %hd.telnet.port = $did(3).text
  %hd.telnet.info $1-
  sockopen telnet $did(1).text $did(3).text
  window -exk[9] @telnet Verdana 10
  aline -p @telnet 7Trying to connect to $did(1).text on port $did(3).text
  if ($sock(telnet).status == active) { aline 1 @telnet Already connected }
}
on *:input:*: {
  if ($active == @telnet) {
    if ($sock(telnet).status == $null) { aline 1 @telnet 4Not connected | halt }
    else sockwrite -nt telnet $1-
    aline 1 @telnet 4[15 $+ $nick $+ 4]15 $1-
    halt
  }
}
on *:sockopen:telnet: {
  if ($sockerr > 0) { aline 4 @telnet Cannot connect to %hd.telnet.addy | return }
  else aline 7 @telnet Connection opened to %hd.telnet.addy
}
on *:sockread:telnet: {
  sockread %hd.info
  aline 15 @telnet $ansi2mirc(%hd.info)
}
on *:sockclose:telnet: {
  aline 1 @telnet 7Connection to %hd.telnet.addy closed.
}
alias closetel {
  if ($sock(telnet).status == $null) { halt }
  sockclose telnet | aline 1 @telnet 7Connection to %hd.telnet.addy closed.
}
menu @telnet {
  Disconnect:closetel
  Open New:sockclose telnet  | dialog -m telnet telnet
  -
  Clear Buffer:clear @telnet
}


Can somebody please explain to me what I am doing wrong... hitting me with a big stick might help :P


GigIRC Network Admin
irc.gigirc.com
Re: Question on aline... [Re: Trixar_za] #174731 11/04/07 10:45 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
It looks to me like you're reading in a line that's returning a $null value. Try this little modification
Code:
on *:sockread:telnet: {
  if $sockerr { echo -a $sockerr | halt }
  else {
    sockread %hd.info
    aline 15 @telnet $ansi2mirc(%hd.info)
  }
}


Re: Question on aline... [Re: RusselB] #174755 12/04/07 10:48 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Same error. After throwing in some pre and post echo's in, My best guess is a non-standard ansi escape code that is causing the problem. Here is some echo'd text:

You chat, 'same error, seems to be something to do with a ANSI escape code that mIRC doesn't support...'

1503You chat, 'same error, seems to be something to do with a ANSI escape code that mIRC doesn't support...151503'15

-
* /aline: insufficient parameters (line 46, Mudclient.mrc)

Honestly I am stumped with this one.


GigIRC Network Admin
irc.gigirc.com
Re: Question on aline... [Re: Trixar_za] #174764 12/04/07 02:22 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
The telnet socket is returning lines that contain no (0) characters. It seems that /aline doesn't like adding blank lines to windows. To solve this, all I did was transform null lines into something that mIRC accepts, but still looks blank (2 ctrl+b in this case).

Code:
on *:sockread:telnet: {
  sockread %hd.info
  %hd.info = $ansi2mirc(%hd.info)
  aline 15 @telnet $iif($len(%hd.info),%hd.info,)
}


Also, you should consider adding code to close the socket or cancel connection if the previous socket is still open. At present, if you try to connect twice, it gives a socket in use message.

-genius_at_work

Re: Question on aline... [Re: genius_at_work] #174916 14/04/07 09:53 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Yeah, Thanks smile. I did find that it deleted lines though so I went the replace route.. works well only it's seems slightly redundent, can you guys think of a better way to check for the ANSI escape codes that aren't used as colours?

The Current Code:
Code:
menu status,menubar,query,channel {
  WormholeMUD
  .Connect:dialog -ma WormholeMUD WormholeMUD
}
dialog WormholeMUD {
  title "WormholeMUD"
  size -1 -1 200 135
  edit "mud.wormhole.se", 1, 5 25 190 20, autohs
  text "Port", 2, 6 47 50 20
  edit "4000", 3, 5 65 190 20, autohs
  button "Connect", 4, 5 95 60 30, ok
  button "Cancel", 5, 135 95 60 30, cancel
  box "Remote Host:", 6, 0 1 200 135
}
on *:dialog:WormholeMUD:sclick:4: {
  %mud.WormholeMUD.addy = $did(1).text
  %mud.WormholeMUD.port = $did(3).text
  %mud.WormholeMUD.info $1-
  sockopen WormholeMUD $did(1).text $did(3).text
  window -exk[9] @WormholeMUD Fixedsys 9
  aline -p @WormholeMUD 7Trying to connect to $did(1).text on port $did(3).text
  if ($sock(WormholeMUD).status == active) { aline 1 @WormholeMUD Already connected }
}
on *:input:*: {
  if ($active == @WormholeMUD) {
    if ($sock(WormholeMUD).status == $null) { aline 1 @WormholeMUD 4Not connected | halt }
    else sockwrite -nt WormholeMUD $1-
    aline 15 @WormholeMUD 4[ $+ $nick $+ 4] $1-
    halt
  }
}
on *:sockopen:WormholeMUD: {
  if ($sockerr > 0) { aline 4 @WormholeMUD Cannot connect to %mud.WormholeMUD.addy | return }
  else aline 7 @WormholeMUD Connection opened to %mud.WormholeMUD.addy
}
on *:sockread:WormholeMUD: {
  :nextread
  if ($sockerr > 0) { return }
  else {
    sockread -fn %mud.info
    if ($sockbr == 0) { return }
    if (%mud.info == $null) { %mud.info =  }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    if ( isin %mud.info) { %mud.info = $replacex(%mud.info,,$ctrl) }
    %mud.info2 = $ansi2mirc(%mud.info)
    if %mud.info2 = $null { %mud.info2 =  }
    aline -p 15 @WormholeMUD %mud.info2
    goto nextread
  }
}
on *:sockclose:WormholeMUD: {
  aline 15 @WormholeMUD 7Connection to %mud.WormholeMUD.addy closed.
}
alias closetel {
  if ($sock(WormholeMUD).status == $null) { halt }
  sockclose WormholeMUD | aline 15 @WormholeMUD 7Connection to %mud.WormholeMUD.addy closed.
}
menu @WormholeMUD {
  Disconnect:closetel
  Open New:sockclose WormholeMUD | dialog -m WormholeMUD WormholeMUD
  -
  Clear Buffer:clear @WormholeMUD
}


GigIRC Network Admin
irc.gigirc.com
Re: Question on aline... [Re: Trixar_za] #174920 14/04/07 02:34 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I would just put all of the $replacex stuff into one command rather than multiple IFs and $replacex's.

if([ isin %mud.info) { %mud.info = $replacex(%mud.info,code1,$ctrl,code2,$ctrl,code3,$ctrl,etc,etc) }

Of course, you can also do that without the IF.


Invision Support
#Invision on irc.irchighway.net
Re: Question on aline... [Re: Riamus2] #174938 14/04/07 04:17 PM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Originally Posted By: Riamus2
I would just put all of the $replacex stuff into one command rather than multiple IFs and $replacex's.

if([ isin %mud.info) { %mud.info = $replacex(%mud.info,code1,$ctrl,code2,$ctrl,code3,$ctrl,etc,etc) }

Of course, you can also do that without the IF.


Was thinking something similar, but the code you use is the start of a standard ANSI escape code, so all that would do is strip all of them, including the color ones. What I have noticed is that it's always control code number;number and f, maybe that is the key smirk


GigIRC Network Admin
irc.gigirc.com
Re: Question on aline... [Re: Trixar_za] #174950 14/04/07 08:24 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It wouldn't strip anything except what you put in there. Like I said, the IF isn't really necessary. You would specifically put all of the codes into the $replacex like I was showing.

Of course, regex may be a simpler way to do something like this if there is a specific pattern to follow.


Invision Support
#Invision on irc.irchighway.net
Re: Question on aline... [Re: Riamus2] #174954 15/04/07 01:37 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Regex seems like a great idea, thanks. One last question... can this script be made to run as a multi-player bot, or does that mean I will need to open sockets for each one...?


GigIRC Network Admin
irc.gigirc.com
Re: Question on aline... [Re: Trixar_za] #174977 15/04/07 10:56 AM
Joined: Jan 2007
Posts: 259
K
Kardafol Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
You will need to open one socket per player.
Another question: Does everything you want filtered start with
""? or something similar?

Last edited by Kardafol; 15/04/07 11:00 AM.

Those who can, cannot. Those who cannot, can.
Re: Question on aline... [Re: Kardafol] #174979 15/04/07 11:21 AM
Joined: Feb 2007
Posts: 75
T
Trixar_za Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
Well, more in a similar format as "", but the numbers always change. The first part is the standard ANSI escape code, the numbers are values and the f identifies what it's meant to do, in this case position the cursor to the correct place on the screen. Hope that gives you a basic idea.

Thanks on answering the socket question for me smile


GigIRC Network Admin
irc.gigirc.com