Re: [Code] [help] Prompt

From: Daniel Koepke (dkoepke@california.com)
Date: 02/02/97


On Sun, 2 Feb 1997, FraG wrote:

> Ive been investing sometime to decrese meanigless output in mud, to both
> decrease lag for players, and bandwidth use.. Anyway, one thing I saw 
> recently in a mud called Asylum (havent had any luck talking with IMPS 
> yet) was that while fighting, instead of sending the prompt after each 
> round, and the cycling, they kept the prompt at the bottom of screen...

There are ANSI codes to limit the screen size.  It is "\x1b[<x>;<x>r".
You can make the prompt stay put by doing the following (this is just a
list of what ANSI codes and in what order you'd need to send to
implement this):

  make sure you're in full screen (\x1b[0;24r)
  save the cursor position (there is a code, I just don't know it)
  position cursor at line 23 (\x1b[23;0f)
  clear the line (\x1b[2K)
  reposition cursor at line 23 (\x1b[23;0f) *
  write out the prompt
  restore cursor position (see comment for 'save')
  set back to less-than-full screen (\x1b[0;22r)

In this way, it will update the prompt which will stay at line 23.  I
did this for a status bar, with the prompt underneath.  It's a good idea
to put the prompt on line 23, if it was on 24 the "return" the player
presses would probably cause scroll.

Now, you need to decide how often (or better yet, WHY) you'd update the
prompt at the bottom.  All those ANSI codes will be a drag on some
systems.  Also, not every system will support all of the above codes,
even the ones that support ANSI.  So, keep it at a toggle and seperate
from everything else.  As for how I decided when to update my status
bar: whenever the data on it changed.  Everytime you update their
status bar is when the old data doesn't match the new.  I had something
like:

  struct old_status_data {
     int hitp;
     int move;
     int psionic;
     int coins;
  };

This was put in the char_data structure.  Now, when we looped around in
main_loop, I added my own loop through the descriptor_list.  If the
person had a character logged in (d->character) and their old_status
information was different from the current, I'd update the entire status
bar.  Why the whole one?  Imagine this as the status bar:

  Hitp: 359  Move: 100  Psi: 49 / Gems: 4  Gold: 24  Silver: 0 Copper: 0

Now, the player's current information is put into their old_status
structure upon display of this status bar.  Then the person takes a
step, thus their moves decrease to say, 96.  If we just made it position
itself at the end of "Move: " and put 96, it'd show: "Move: 960".  Why?
There's more places in 100 than in 96.  You could, of course, position
at that one point, put spaces until the beginning of "Psi: ", and then
move back to after "Move: " and write it -- but why bother?  You're
ending up using 4 or 5 ANSI codes, regardless of which way to do it.

This doesn't apply, I guess to the battle prompt.  You pretty much have
to clear the line and write the new prompt.  Anyway, good luck! :)


--
Daniel Koepke
dkoepke@california.com
Forgive me father, for I am sin.


+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST