Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 04-05-2004, 01:35 PM   #1
Jaegar
New Member
 
Join Date: Apr 2002
Posts: 14
Jaegar is on a distinguished road
I have just implemented an old jog command that I had found but am having a problem with it accepting some of the input.

The code is supposed to accept numbers before the direction and interpret it into the movement as well as accept an "o" for open then a direction to open.

Here is how the code should read the directions input

jog 12eos3ses4w

However the code will not accept the #'s and the open is not recognized either.

Here is the code from act_move.c

This is for a Rom2.4 mud.


 void do_jog( CHAR_DATA *ch, char *argument )
  {
     char buf[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
     char *p;
     bool dFound = FALSE;

     if (!ch->desc || *argument == '\0')
     {
        send_to_char("You run in place!\n\r", ch);
        return;
     }

     buf[0] = '\0';
     while (*argument != '\0')
     {
        argument = one_argument(argument,arg);
        strcat(buf,arg);
     }

     for ( p = buf + strlen(buf) -1; p >= buf; p-- )
     {
        if (!isdigit(*p))
        {
           switch( *p )
           {
              case 'n':
              case 's':
              case 'e':
              case 'w':
              case 'u':
              case 'd': dFound = TRUE;
                 break;
              case 'o':
                 break;
              default: send_to_char("Invalid direction!\n\r",ch);
                 return;
           }
        }
        else if (!dFound) *p = '\0';
     }

     if (!dFound)
     {
        send_to_char("No directions specified!\n\r",ch);
        return;
     }

     ch->desc->run_buf = str_dup( buf );
     ch->desc->run_head = ch->desc->run_buf;
     send_to_char("You start running...\n\r",ch);
     return;
  }


Any help would be appreciated.

Jaegar
Jaegar is offline   Reply With Quote
Old 04-06-2004, 11:03 AM   #2
erdos
 
Posts: n/a
Is that the ENTIRE snippet?  It looks to me like it goes to all the work of storing the dirs and all, but never does anything with them.  you sure there isnt something else you forgot to put in, in update.c or something?

If I were to code this from scratch in SMAUG i would use skill timers, see for example do_dig, do_search.  But I'm not sure if your codebase has that ability (it looks very similar to smaug so it might)

On an unrelated subject, these jog/jet/run commands are utterly stupid and never ever ever work well.  my recommendation is, leave it the heII out.
  Reply With Quote
Old 04-07-2004, 04:00 AM   #3
Davairus
Member
 
Join Date: Jun 2002
Posts: 157
Davairus is an unknown quantity at this point
You are going to need to have an update function in update.c, have it called every half-second or something, and just put a call to do_jog in it.  It'll look something like this.

[code]
void jog_update(void)
{
  CHAR_DATA *wch;
   for( wch = char_list; wch != NULL; wch = wch->next)
      if(IS_AWAKE(wch) && ch->position == POS_STANDING)
          do_jog(ch, ch->jogdata);
}
[/quote]

then in update_handler, make sure your update is getting called every 3 pulses or something.  maybe copy the aggr_update framework, thats close enough

I am not claiming thats going to work perfectly or anything, its just to get you started with something working, if you can find a better implementation go with that.
Davairus is offline   Reply With Quote
Old 04-07-2004, 07:33 PM   #4
Zakmyrr
New Member
 
Join Date: Jan 2003
Posts: 1
Zakmyrr is on a distinguished road
Quote:
Originally Posted by (erdos @ April 06 2004,11<!--emo&[img
http://www.topmudsites.com/iB_html/non-cgi/emoticons/wow.gif[/img])]On an unrelated subject, these jog/jet/run commands are utterly stupid and never ever ever work well.  my recommendation is, leave it the heII out.
On the contrary, Aardwolf has implemented the run command very nicely.  An example of a run involving opening a door would look something like this:  run 3sen10ed; open n; ne2n

Perhaps the owner (Lasher) would help you out?

Aardwolf
Zakmyrr is offline   Reply With Quote
Old 04-09-2004, 04:41 AM   #5
Dre
Member
 
Join Date: Jun 2002
Location: the Netherlands
Posts: 65
Dre is on a distinguished road
I can understand the o is giving problems as you break from the switch but you don't do anything with it.

I wonder what your specs really are, what do you want to achieve?

If you want them to set a path and then walk that path you have to call move_char a couple of times either here (which will make it really quick) or in update.c or something similar.

But seems to me you need to think up how you want to parse the buffer first. I'd read in the buffer for numbers till I find a char. Put any numbers you find in a buffer and then you get the char, you start moving the char. Then when you are done moving it X times then parse the next part etc.

When you get to the character open you read the next char for direction open the door and then continue parsing. Perhaps you also want to make a check if a door really opened or after finding one direction in error that the function will stop parsing as the rest of the path will most likely be void as well.

Greetings,
Dre is offline   Reply With Quote
Reply


Thread Tools


Jog Command - Similar Threads
Thread Thread Starter Forum Replies Last Post
Features of a MUD command parser. Drealoth Advanced MUD Concepts 15 04-27-2006 02:08 PM
command processor Dubthach MUD Coding 4 10-26-2004 11:01 PM
Switch command Verboden Faction MUD Coding 8 05-15-2003 09:31 PM
Command trigger for progs Jaegar MUD Coding 1 04-03-2003 06:41 PM
Chown Command Verboden Faction MUD Coding 9 03-23-2003 07:12 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 05:28 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014