[DGD] (Newbie Question #2) [user->message]

Jason Murray jason.murray at charter.net
Tue Aug 26 06:00:24 CEST 2003


Hi,

I would leave message() alone and begin by allowing the user to toggle
whether he or she wants to (or can) see ansi colors, both as a command
and at logon. Then use a query on the user's preference to build the
string passed to message(). The implementation is up to you. The
simplest, perhaps, is something like this:

#include "ansi_defs.h"

if (user->use_ansi()) {
    str = ANSI_FG_RED + "hello, world" + ANSI_END;
} else {
    str = "hello, world";
}

user->message(str);

Jason


On Mon, 2003-08-25 at 22:45, Martyn Ashworth wrote:
> OK.
> 
> I now have another little question. Basing most of my work around the stock
> kernel (i prefer the deep-end when i jump in) i'm trying to write a module
> that will format output onto a users screen depending on whether they have
> ansi enabled or not.
> 
> Looking at the user.c object
> 
> private void tell_audience(string str)
> {
>     object *users, user;
>     int i;
> 
>     users = users();
>     for (i = sizeof(users); --i >= 0; ) {
>      user = users[i];
>      if (user != this_object() &&
>        sscanf(object_name(user), DEFAULT_USER + "#%*d") != 0) {
>        user->message(str);
>      }
>    }
> }
> 
> so in this example would 'user' be the reference to a cloned user.c object?
> 
> in this case is it a case of writing my own "void message(string str)" type
> function to handle the text to display to user or do i need to do some more
> reading?
> 
> please excuse any incorrect terminology, i'm not a programmer by trade, just
> by hobby.
> 
> any pointers gratefully received.
> 
> -=[MJ]=-
> Feeding the herd since 1977.
> 
> _________________________________________________________________
> List config page:  http://list.imaginary.com/mailman/listinfo/dgd
-- 
Jason Murray <jason.murray at charter.net>

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list