[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  No Lists!

No Lists!

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Gregar   (20 posts)  [Biography] bio
Date Fri 19 Dec 2003 06:07 PM (UTC)
Message
Hello Everyone!

New to the forum so bear with me a moment while I gather my bearings.
I have been lurking for a bit, and decided to toss my hat in with a question. BTW Nick, we use the Area Editor for our builds, and life is o much simpler now, thanks for making it available. Now onto my question.

In this thread : http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=560

I was interested in making Mobs and Objects appear as part of a paragraph, instead of the standard Smaug list form, so I applied the code ( Thanks Kelsid) and fired up my game to see what I ended up with.

What I wanted was ... Also here: A rat, a hideous-looking rat, and a rat.

What I got was :
Also here:
A rat looks back at you from the shadows, its red eyes glowing.
, A hideous-looking rat scurries along.
, and A rat looks back you from the shadows, its red eyes glowing.

The long descriptions I can clean up, no trouble there, but as you can see, it is still listing the Mobs in list form, not as a paragraph.

So, any ideas on how to condense this stuff?

Suggestions are welcome, even encouraged. Thanks!
[Go to top] top

Posted by Gregar   (20 posts)  [Biography] bio
Date Reply #1 on Fri 19 Dec 2003 06:48 PM (UTC)
Message
Talking about it helps!

On reflection, I see a line that says,

send_to_char("Also here:\n\r", ch);

The \n\r is of course the prompt to start a new line. If I remove the \n\r following Also here: the display should not start a new line, but continue on in the paragraph, correct?

As written:
Also here:
A rat

\n\r removed:
Also here: A rat

[Go to top] top

Posted by Nick Gammon   Australia  (22,985 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 19 Dec 2003 08:58 PM (UTC)
Message
Yes, you are on the right track by removing the \n entries.

However there is one point you might look at.

The sequence \n\r is not a valid line terminator. I am sure you can get confirmation on the Net somewhere, for instance on this page:

http://www.gammon.com.au/mushclient/mxp.htm

Scroll down to the paragraph "Newlines".

(Disclaimer: I wrote that, so you don't necessarily have to believe it).

Here is one example page that comments on this:

http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01433.html

"Whilst redoing this code, I changed it so the only newline combinations
we allow are '\r', '\n' and '\r\n'. We used to allow '\n\r' which is
not a standard terminator. Other languages such as Java and C#
explicitly allow these three, but not \n\r, and I figured we should be
consistent and do the same."

I note that SMAUG actually uses \n\r quite a bit in the code, but also \r\n to a lesser amount. I am sure someone got confused somewhere, and then duplicated the confusion in further coding.

Personally I would stick to \n and forget the \r. Virtually every client would support line breaks on \n only (MUSHclient generally discards the \r so it doesn't reallly matter if it comes first or second).

The reason for this is that many MUDs started as Unix servers, where \n alone is the line terminator. Then when people started writing Windows clients they had to recognise \n as the line terminator, without insisting on also getting the \r character.

In case anyone is wondering, these are:

\r (hex 0D) - carriage return - returns the cursor to column 1
\n (hex 0A) - line feed - starts a new line

I think the reason for the order \r\n was because of the old teletype terminals. When you wanted to start a new line, you sent \r first (carriage return) which would start the carriage (the thing with the print head on it) sliding slowly back to column one. Then you sent a \n (line feed) which made the cogs feed a line. The carriage return took longer, which is why you did it first.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gregar   (20 posts)  [Biography] bio
Date Reply #3 on Fri 19 Dec 2003 11:46 PM (UTC)
Message
Thanks Nick,
I too had taken note of both \n\r and \r\n being used in the stock Smaug code, but I am from the old school where we were taught if it ain't broke dont fix it. My guess is that its reading whats there, and disreguarding the irrelevant characters.

It is nice to know the bad ones can be removed and not break anything though, this will give my new coders something to do between projects. Heh.

Gregar
[Go to top] top

Posted by Gregar   (20 posts)  [Biography] bio
Date Reply #4 on Sun 21 Dec 2003 06:55 AM (UTC)
Message
There appears to be a problem in the snippet Kelsid provided, which likes to add a . on a new line. I am still tracking down the problem, but as written it does the following:

Also here:
A rat.
.
, A rat, and A rat.
.

I suspect that the area editor may pop one of those periods in there automatic from the long name of the mob, but I will keep at it.

Question about IWear however. I have managed to condense the EQ, INV lists to a single paragraph, but I am getting things like this;

You are wearing: <used as a light> a ball of light, <worn on the head> an iron helmet.

I find the item location redundant, as where else would you wear a helmet, heh. I would like very much to make that go away. So what we start with is:
if ( !found )
{
send_to_char( "\n\r", ch );
if ( victim != ch )
act( AT_PLAIN, "$N is wearing:", ch, NULL, victim, TO_CHAR );
else
act( AT_PLAIN, "You are wearing:", ch, NULL, NULL, TO_CHAR );
found = TRUE;
}
if( (!IS_NPC(victim)) && (victim->race>0) && (victim->race<MAX_PC_RACE))
send_to_char(race_table[victim->race]->where_name[iWear], ch);
else
send_to_char( where_name[iWear], ch );
send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
send_to_char( "\n\r", ch );
}


Will removing all the iWear references fix this?
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,251 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]