Up to Main Index                               Up to Journal for May, 2013

                     JOURNAL FOR THURSDAY 16TH MAY, 2013
______________________________________________________________________________

SUBJECT: Simple ≠ Simple
   DATE: Thu May 16 22:09:09 BST 2013

I had a very nice email asking if I could add basic say and talk commands.
Then WolfMUD could be used as a mini local chat server while others were
waiting for more exciting stuff to be added. Well that sounded like a good
idea and I thought I'd give it a go last night. It turned out to be very easy
to implement:


  func (m *Mobile) say(cmd *command.Command) (handled bool) {
    if len(cmd.Nouns) == 0 {
      cmd.Respond("[RED]Was there anything in particular you wanted to say?")
    } else {
      message := strings.Join(cmd.Input[1:], ` `)
      cmd.Broadcast([]thing.Interface{cmd.Issuer},
        "[CYAN]%s says: %s", cmd.Issuer.Name(), message,
      )
      cmd.Respond("[YELLOW]You say: %s", message)
    }
    return true
  }


I decided to implement it for the mobile package rather than the player
package. That way later on it'll be easy to have mobiles say things when
scripted for example.

However in practise it proved very clunky. It's difficult chatting when every
time you receive a message or something happens your input gets chopped up
into little broken bits.

Oh what to do? I didn't really want to write my own client right now. What I
really wanted was separate input and output areas so they didn't interfere
with each other. Was it possible to do that with the minimal telnet stuff I
had working? I started tinkering... a few hours later my code was a mess of
ad hoc edits but:


  WolfMUD Copyright 2012 Andrew 'Diddymus' Rolfe

      World
      Of
      Living
      Fantasy


  Fireplace
  You are in the corner of a common room in the Dragon's Breath tavern. There
  is a fire burning away merrily in an ornate fireplace giving comfort to
  weary travellers. Shadows flicker around the room, changing light to
  darkness and back again. To the south the common room extends and east the
  common room leads to the tavern entrance.
  You can see A curious brass lattice here.
  You can see A small green ball here.
  You can see A small red ball here.
  You can see An iron bound chest here.
  You can see Player 3 here.

  You can see exits: East, Southeast, South
  You sneeze. Aaahhhccchhhooo!
  Player 3 says: One simple chat server! ;)
  ----------------------------------------------------------------------------
  >


The dashed line will become a status line later on. Below that is your input
line. Above it is a scrolling output area. I've tested it on Linux with a
plain telnet client and Windows using the Windows telnet client and putty in
raw mode. It seems to work quite well but the Windows telnet client keeps
inserting a lot of extra line feeds into the output area which I need to look
into.

Now I'm left pondering a few things. Do I clean up all the hacks and make this
permanent? If I do then should I also keep the original telnet processing as a
fallback in case it does not work with some clients - or some players just
don't like it? When you hit enter should your command also appear in the
output area? Does it add much more network traffic? Can it be applied
transparently without littering the source with code to handle all of this?

Just because something seems simple doesn't mean it's easy ;)

--
Diddymus


  Up to Main Index                               Up to Journal for May, 2013