redit_snake.txt
snippets · 2.6 KB · 2010-03-30
Snake redit: chains together the dig command through redit.
Download « Back to the snippets list
// Snake redit command for chaining together the dig command.
// You should be sure you have installed the snippet for using dig
// without vnum arguments already, this will not work without it. - Runter
REDIT (redit_snake) {
ROOM_INDEX_DATA *in_room, *tracer;
char holder[6], *ptr;
int count = 0;
if (ch->in_world)
return FALSE;
in_room = ch->in_room;
if (*argument == 0) {
send_to_char("snake <arg>, example: snake nneess\r\n", ch);
return FALSE;
}
tracer = ch->in_room;
ptr = holder;
for(;*argument != 0;) {
char_from_room(ch);
char_to_room(ch, tracer);
switch(*argument) {
default:
if (*argument < '0' || *argument > '9') {
send_to_char("Error in syntax. Read help snake for more details.\r\n", ch);
return FALSE;
}
while (*argument >= '0' && *argument <= '9') {
*ptr = *argument;
*(ptr+1) = 0;
++argument;
}
count = atoi(holder);
break;
case ' ':
tracer = in_room;
break;
case 'n':
redit_north(ch, "dig");
tracer = ch->in_room->exit[0]->u1.to_room;
break;
case 'e':
redit_east(ch, "dig");
tracer = ch->in_room->exit[1]->u1.to_room;
break;
case 's':
redit_south(ch, "dig");
tracer = ch->in_room->exit[2]->u1.to_room;
break;
case 'w':
redit_west(ch, "dig");
tracer = ch->in_room->exit[3]->u1.to_room;
break;
case 'u':
redit_up(ch, "dig");
tracer = ch->in_room->exit[4]->u1.to_room;
break;
case 'd':
redit_down(ch, "dig");
tracer = ch->in_room->exit[5]->u1.to_room;
break;
}
if (count == 0)
++argument;
else
--count;
}
char_from_room(ch);
char_to_room(ch, in_room);
return TRUE;
}
/* The following is the help file.
help snake
{x
syntax snake <directions>
{x
Example:
snake nnee
{x
This will create a path of rooms 2 north and then 2 east from you.
{x
Example:
snake 2n2e
{x
This will create a path of rooms 2 north and then 2 east from you, not
unlike above.
{x
Example:
snake 2n2e 2s2w
{x
This will create a path of rooms 2 north and then 2 east, then create
a second path 2 south and 2 west.
*/