stringext.txt
snippets · 1.4 KB · 2010-03-30
String extension: a tiny extension to strip an extended description from an object.
Download « Back to the snippets list
/*
Just a tiny extension of string to let it strip an extended from an object.
It should be easy to generalize this (as I generalized it from oedit) to any
command you need. The extra_descr_data struct is a linked list, which means
you've just gotta be careful about assigning the ->next member when you chop a desc
out of the list. No credit necessary, pretty much c&p from olc_act.c.
*/
// Add the stuff between the comments to do_string in act_wiz.c.
send_to_char( "Syntax: oset <object> ed <keyword> <string>\n\r",
ch );
return;
}
/*
* string obj <name> 'keyword' erase : removes an extended with string.
*
* Same thing as oedit's ed delete, but handy to have with string.
*
* -SainosAU@yahoo.com
*/
else if ( !strcmp( argument, "erase" ) )
{
EXTRA_DESCR_DATA *ped = NULL;
for ( ed = obj->extra_descr; ed; ed = ed->next )
{
if ( is_name( arg3, ed->keyword ) )
break;
ped = ed;
}
if ( !ed )
{
send_to_char( "There is no such extended on this object.\n\r", ch );
return;
}
if ( !ped )
obj->extra_descr = ed->next;
else
ped->next = ed->next;
free_extra_descr( ed );
send_to_char( "Extra description removed.\n\r", ch );
return;
}
/* end: string obj <name> 'keyword' erase */
strcat(argument,"\n\r");
ed = new_extra_descr();