I'm trying to create a command that allows players to edit their own rooms but am having trouble getting it to work. If i copy what's under redit it works but only kinda of. If someone could maybe point me in a better direction that'd be wonderful or explain how one does create an editing buffer.
-Mirrodan
Sorry for being to brief. I guess i'll start with what I want to do and then what i've done.
Ok what i need to do is allow a player to edit a room
description w/o using redit as it'll be for the home they
own. So far with the player owned homes code i've put in
it allows them to buy and sell a home (i.e. room) and edit
the name of the home but, I can't figure out how to get it
to allow them to edit the room description.
I took a look at redit and tried to copy and past but, and
that seemed to work at first sort of. However there was a
bug in it that when you did /s to leave the buffer it for
some reason thought you were still in it until you typed
homebuy desc...( the command i used ).
-Everett
OK, that's a little more specific. :-)
You probably didn't reset the substate. Could you paste the first part of the code - the one that deals with the buffer?
else if ( !str_cmp( arg, "desc" ) )
{
if ( ch->PlayerHomeVnum == '\0' )
{
send_to_char( "&RYou do not own a home!\n\r&w", ch);
return;
}
if ( IS_SET( room->room_flags , ROOM_EMPTY_HOME ) )
{
send_to_char( "&RThis room can't be modified it's not a home!\n\r&w", ch);
return;
}
if ( IS_SET( room->room_flags, ROOM_PLR_HOME) && (ch->PlayerHomeVnum != ch->in_room->vnum))
{
send_to_char( "&RNow would we walk into your home and draw on the walls ?", ch );
return;
}
if ( IS_SET( room->room_flags, ROOM_PLR_HOME) && (ch->PlayerHomeVnum == ch->in_room->vnum))
{
switch( ch->substate )
{
default:
break;
case SUB_PLRROOM_DESC:
room = ch->dest_buf;
if ( !room )
{
bug( "redit: sub_room_desc: NULL ch->dest_buf", 0 );
room = ch->in_room;
}
STRFREE( room->description );
room->description = copy_buffer( ch );
stop_editing( ch );
ch->substate = ch->tempnum;
return;
}
if ( !str_cmp( arg, "desc" ) )
{
if ( ch->substate == SUB_REPEATCMD )
{
ch->tempnum = SUB_REPEATCMD;
} else
{
ch->tempnum = SUB_NONE;
ch->substate = SUB_PLRROOM_DESC;
ch->dest_buf = room;
start_editing( ch, room->description );
}
if ( ch->substate == SUB_REPEATCMD )
{
ch->substate = SUB_RESTRICTED;
interpret( ch, origarg );
ch->substate = SUB_REPEATCMD;
ch->last_cmd = do_buyhome;
}
return;
}
}
return;
}
fold_area( room->area, room->area->filename, FALSE );
do_save( ch , "" );
return;
i know that's a lot and it more then likely is garbled but i'm trying :P
-Mirrodan
OK first things first you need to use the code tag to indent that stuff to make it properly readable. :P Grumpy ol' coders like me like having everything all neatly laid out.
Second thing, what function is all that in? You start with an 'else if' but where is the first if? What all is going on before that?
OK, first problem is that you haven't quite reproduced the redit desc thing. The first thing is that the substate commands are at the [i]top[/i] of the function, not buried in the middle.
Second, you have two handlers for RPT_CMD, but one of them should be for SUB_PLRROOM_DESC - like in redit.
What I would do if I were you, would be to more closely examine the redit case. You could also look at oset, mset and even the bio command, for other examples of this.
And at worse, you could always make a separate command that doesn't have to deal with all the sub commands e.g. "buy" "sell" "name" "desc" etc.
I got it for now I hope it continues to work i moved the switch statement out from where it was to the beginning and made a few other modifications so hopefully it's good to go now!
Thanks Again,
Mirrodan
Well I fixed that it wasn't to hard once i had had some sleep and took another look at it. The code is almost done for those you want player owned homes in their mud just let me know i'll hook u up with the code.
-Mirrodan