[Coldstuff] Prompts and Queues

Adam Cormany coldstuff@cold.org
Mon, 18 Nov 2002 15:21:36 -0800 (PST)


Sorry for the delay. The flu got me.

Anyways, here is what I did. I'm not sure what would
be the best method of explaining what I did, so here
are the steps. You're going to have to modify the
stuff I say because I did 2 prompts, 1 normal prompt
and 1 combat prompt and there are methods in here that
you will not have. Sorry for the huge email. Hopefully
I haven't miss anything. I did this 2ish years ago:

1) Create a variable on $body called 'prompt'.
2) Create a method called $body.get_prompt with:
-----
    return prompt || "Type HELP PROMPT";
-----
3) Create a method called $body.set_prompt with:
-----
    arg value;

    prompt = value;
-----
4) Create a method called $body.prompt_cmd with:
-----
    arg cmd, cmdstr, value;

    if (!value) {
        if (!prompt)
            prompt = "Type HELP PROMPT ";
        return "You prompt string is: " +
.get_prompt();
    } else if (value == "off") {
        .set_prompt("> ");
        return "Prompt off.";
    } else {
        .set_prompt(value + " ");
        return "New prompt string set to: " +
.get_prompt();
    }
-----
5) Create a method called $body.show_prompt with:
-----
  var line;

  line = .prompt_mode() == 'combat ?
.get_combat_prompt() : .get_prompt();
  line = strsed(line, "\%h", tostr(.hit()), "gc");
  line = strsed(line, "\%H", tostr(.hit_limit()),
"gc");
  line = strsed(line, "\%m", tostr(.mana()), "gc");
  line = strsed(line, "\%M", tostr(.mana_limit()),
"gc");
  line = strsed(line, "\%v", tostr(.move()), "gc");
  line = strsed(line, "\%V", tostr(.move_limit()),
"gc");
  line = strsed(line, "\%x", tostr(.xp()), "gc");
  line = strsed(line, "\%g", tostr(.gold()), "gc");
  line = strsed(line, "\%n", .get_name(), "gc");
  line = strsed(line, "\%p", (.get_cwd())[2], "gc");
  line = strsed(line, "\%R",
tostr(.location().rnum()), "gc");
  line = strsed(line, "\%r", .location().full_fname(),
"gc");
  line = strsed(line, "\%t", $time.format("%I:%M %p"),
"gc");
  if (valid(.fighting()))
      line = strsed(line, "\%e",
tostr(.fighting().hit()), "gc");
  if (.is($builder))
      line = strsed(line, "\%s", .active_editor() ?
.active_editor().session_name() : "No Session", "gc");
 
.non_terminated_tell_color(.ansi_value(.prompt_mode()
== 'combat ? "combat_prompt" : "prompt", line));
-----
Most of this code in this step will do nothing for you
because it's mostly methods I've created to report
stats of the player and also to display the text in
color. You'll have to create your own case statement
of things you want to show on your users prompts and
you'll have to change the last line since you will not
have any of its methods.
6) At the end of $user.parse_line, before:
-----
      catch any
          task_connections =
task_connections.del(task_id());
      return rval;
-----
   add the line:
      .show_prompt();

That should be it. Word of caution though. Be careful
editing $user.parse_line. You mess something up in it
and you wont be able to do much of anything since all
your commands go through it. Just a prewarning:) I've
had to restart Cold/Genesis many times because of
messups in this method...

I'm sure I've missed something and I'm sure there is a
much better way to handle this, so if anyone has
criticism of my code or questions or whatever, feel
free to say it. I'm always looking for a better way to
do things in Cold.

Adam

--- Roy Sutton <roys@mindspring.com> wrote:
> Adam,
> 
> Yes, that's exactly what I was asking for.  I'd love
> to take a look at what 
> you did.
> 
> As to the 2nd question it may be unclear what I was
> asking.  I think I have 
> a handle on where to look for the functionality I
> need.
> 
> Roy
> 
> At 08:16 AM 11/4/2002, Adam Cormany wrote:
> >If you mean on the prompt system, you want a prompt
> >configurable to the user where they can show only
> >their Hit Points, Moves, etc, yes, I've done this.
> >I'll post if anyone is interested in it.
> >
> >--- Roy Sutton <roys@mindspring.com> wrote:
> > > Questions for you guru types:
> > >
> > > 1)  I'd like to add a prompt system to Cold. 
> Has
> > > someone already tackled this?
> > >
> > > 2)  I'd like to be able to have certain commands
> go
> > > into a queue before
> > > processing (to prevent concurrent commands which
> > > should take a while to
> > > execute in game time).  Has someone tackled this
> one
> > > before?  If not, some
> > > thoughts on implementation details would be
> > > appreciated.
> > >
> > > Roy
> > >
> > > _______________________________________________
> > > Cold-Coldstuff mailing list
> > > Cold-Coldstuff@cold.org
> > >
> http://web.cold.org/mailman/listinfo/cold-coldstuff
> >
> >
> >__________________________________________________
> >Do you Yahoo!?
> >HotJobs - Search new jobs daily now
> >http://hotjobs.yahoo.com/
> >_______________________________________________
> >Cold-Coldstuff mailing list
> >Cold-Coldstuff@cold.org
> >http://web.cold.org/mailman/listinfo/cold-coldstuff
> 
> _______________________________________________
> Cold-Coldstuff mailing list
> Cold-Coldstuff@cold.org
> http://web.cold.org/mailman/listinfo/cold-coldstuff


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com