|
Trixar_za
|
Trixar_za
|
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:
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
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
It looks to me like you're reading in a line that's returning a $null value. Try this little modification on *:sockread:telnet: {
if $sockerr { echo -a $sockerr | halt }
else {
sockread %hd.info
aline 15 @telnet $ansi2mirc(%hd.info)
}
}
|
|
|
|
Trixar_za
|
Trixar_za
|
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:
[0;37m[32mYou chat, 'same error, seems to be something to do with a ANSI escape code that mIRC doesn't support...[0;37m[0;37m[32m'[0;37m
1503You chat, 'same error, seems to be something to do with a ANSI escape code that mIRC doesn't support...151503'15 [24;1f[J - * /aline: insufficient parameters (line 46, Mudclient.mrc)
Honestly I am stumped with this one.
|
|
|
|
Joined: Oct 2005
Posts: 1,671
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,671 |
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).
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
|
|
|
|
Trixar_za
|
Trixar_za
|
Yeah, Thanks  . 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:
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 ([24;1f isin %mud.info) { %mud.info = $replacex(%mud.info,[24;1f,$ctrl) }
if ([20;1f isin %mud.info) { %mud.info = $replacex(%mud.info,[20;1f,$ctrl) }
if ([J isin %mud.info) { %mud.info = $replacex(%mud.info,[J,$ctrl) }
if ([21;1f isin %mud.info) { %mud.info = $replacex(%mud.info,[21;1f,$ctrl) }
if ([23;1f isin %mud.info) { %mud.info = $replacex(%mud.info,[23;1f,$ctrl) }
if ([23;63f isin %mud.info) { %mud.info = $replacex(%mud.info,[23;63f,$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
}
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
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.
|
|
|
|
Trixar_za
|
Trixar_za
|
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 
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
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.
|
|
|
|
Trixar_za
|
Trixar_za
|
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...?
|
|
|
|
Joined: Jan 2007
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Jan 2007
Posts: 259 |
You will need to open one socket per player. Another question: Does everything you want filtered start with "[23;63f"? or something similar?
Last edited by Kardafol; 15/04/07 11:00 AM.
|
|
|
|
Trixar_za
|
Trixar_za
|
Well, more in a similar format as "[23;63f", 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 
|
|
|
|
|