1. Re: mud
----- Original Message -----
From: "Michelle Rogers" <michellerogers at bellsouth.net>
To: <EUforum at topica.com>
Subject: Re: Fastest Way to...
>
>
> Hello, can someone tell me what is wrong with this? I'm using the hackserv
> as a basis for a mud. I've tried to change it to accomodate telnet, gmud,
> zmud, etc..(basically any client) where it only supported telnet in the
> beginning. I KNOW this is too much code..but i've just been adding stuff in
> trying to make it work and nothing seems to work. I KNOW that I'm
> overlooking something really easy..but I can't figure it out. Can someone
> tell me if you know what is wrong with this?
Might have helped to say what you were trying to achieve. I'm guessing you are
trying to strip out CR and LF characters.
[snip]
> if compare({10},players[charnum][6][(length(players[charnum][6]))]) or
> compare({13},players[charnum][6][length(players[charnum][6])]) then
>
> if compare({10},players[charnum][6][length(players[charnum][6])]) then
>
> players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)]
> end if
>
> if compare({13},players[charnum][6][length(players[charnum][6])]) then
>
> players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)]
> end if
>
> if compare({10},players[charnum][6][length(players[charnum][6])]) then
>
> players[charnum][6]=players[charnum][6][1..(length(players[charnum][6])-1)]
> end if
> junk=players[charnum][6]
>
It might help to make the above a bit more readable...maybe something like ...
sequence lText
lText = players[charnum][6]
if compare({10}, lText[length(lText)]) or
compare({13}, lText[length(lText)]) then
if compare({10}, lText[length(lText)]) then
lText = lText[1..length(lText)-1]
end if
if compare({13}, lText[length(lText)]) then
lText = lText[1..length(lText)-1]
end if
if compare({10}, lText[length(lText)]) then
lText = lText[1..length(lText)-1]
end if
junk = lText
. . .
However, this won't work for a couple of reasons. Firstly, the compare()
function returns a ZERO of the operands are equal. Your code seems to expect it
to return a non-ZERO. Secondly, you are testing to see if the last element of the
text is the sequence '{10}' rather than the character '10'.
Here is a reworking of it ...
sequence lText
integer lEnd
-- Grab text to test.
lText = players[charnum][6]
-- Get the potential length of the text.
lEnd = length(lText)
-- Keep checking unless we have no text.
while lEnd > 0 do
-- Is the current end char at LF or CR?
if find(lText[lEnd], {10,13}) then
-- Yes, so back up one character.
lEnd -= 1
else
-- No, so stop checking.
exit
end if
end while
-- Slice off the part of the text we want.
junk = lText[1..lEnd]
. . .
Hope this helps.
--
Derek