Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Buffers and room desc

Buffers and room desc

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Mirrodan   USA  (28 posts)  Bio
Date Tue 19 Oct 2004 06:56 AM (UTC)
Message
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

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #1 on Tue 19 Oct 2004 08:47 AM (UTC)
Message
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

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Tue 19 Oct 2004 09:49 AM (UTC)
Message
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?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #3 on Tue 19 Oct 2004 10:09 AM (UTC)
Message
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

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Tue 19 Oct 2004 09:20 PM (UTC)
Message
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?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #5 on Tue 19 Oct 2004 09:37 PM (UTC)
Message

void do_buyhome( CHAR_DATA *ch, char *argument )
{
     ROOM_INDEX_DATA *room;
     char		*origarg = argument;
     AREA_DATA *pArea;
     char arg[MAX_INPUT_LENGTH];
 
     if ( !ch->in_room )
         return;
         
     if ( IS_NPC(ch) || !ch->pcdata )
         return;
         
     if ( ch->plr_home != NULL )
     {
         send_to_char( "&RYou already have a home!\n\r&w", ch);
         return;   
     }
     
     room = ch->in_room;
     
     for ( pArea = first_bsort; pArea; pArea = pArea->next_sort )
     {
         if ( room->area == pArea )
         {
             send_to_char( "&RThis area isn't installed yet!\n\r&w", ch);
             return;
         }
     }
     smash_tilde( argument );
     argument = one_argument( argument, arg );
     if ( arg[0] == '\0' )
     {
	   send_to_char( "Usage: Buyhome <options>\n\r", ch );
	   send_to_char( "Options: purchase, sell, description, name\n\r", ch );
	   return;
     }
     // Allows a Player to buy a one room home
     if (!str_prefix(arg,"purchase"))
     {
     
      if ( IS_SET( room->room_flags, ROOM_PLR_HOME))
       {
	    if ( ch->PlayerHomeVnum == ch->in_room->vnum)
	     {
		  send_to_char( "Doh!!! You already own this home!!" , ch);
	      return;
         }
        send_to_char(" Umm you can't buy someone's home out from underneith them !!!", ch);
        return;
       }
      if ( !IS_SET( room->room_flags , ROOM_EMPTY_HOME ) )
       {
	     send_to_char( "&RThis room isn't for sale!\n\r&w", ch);
         return;   
       }
      if ( ch->gold < 100000 )
       {
         send_to_char( "&RThis room costs 100000 credits you don't have enough!\n\r&w", ch);
         return;   
       }
      send_to_char( "&RYou have just purchased a home in the world of Techno-Magicka.\n\r", ch);
      send_to_char( "&RPlease see helpfile \"buyhome\" for the details on how to modify it.\n\r", ch);
     ch->gold -= 100000;
     REMOVE_BIT( room->room_flags , ROOM_EMPTY_HOME );
     SET_BIT( room->room_flags , ROOM_PLR_HOME );
     
     fold_area( room->area, room->area->filename, FALSE );

     ch->plr_home = room;
     ch->PlayerHomeVnum = ch->in_room->vnum;
     do_save( ch , "" );
     return;
     } 
     
     // Allows a player to sell a home they own
     
     else if (!str_prefix(arg, "sell"))
      {
	   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 sold it's for sale!\n\r&w", ch);
         return;   
        }
       if ( IS_SET( room->room_flags, ROOM_PLR_HOME) && (ch->PlayerHomeVnum != ch->in_room->vnum))
        {
	     send_to_char( "&RThis is not your home you can not sell this", ch );
	     return;
        }
        send_to_char("You've now sold your home and 100000 credits have been deposited into your account!\n\r", ch);
        ch->gold += 100000;
        REMOVE_BIT( room->room_flags , ROOM_PLR_HOME );
        SET_BIT( room->room_flags , ROOM_EMPTY_HOME );
     
        fold_area( room->area, room->area->filename, FALSE );

        ch->plr_home = '\0';
        ch->PlayerHomeVnum = '\0';
        do_save( ch , "" );
        return;
     }



here's part of it

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #6 on Tue 19 Oct 2004 09:38 PM (UTC)
Message

// Allows the player to set the home's name
else if ( !str_cmp( arg, "name" ) )
{
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))


STRFREE( room->name );
room->name = STRALLOC( argument );
//ch_printf(ch, " You have set the room's name to %s\r\n", room->name);



fold_area( room->area, room->area->filename, FALSE );
do_save( ch , "" );
return;
}

// The following allows a player to edit the desc of the room. Hopefully.

/* 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;
*/



}



And here's the other part of it.

Sorry i didn't know about the "code" tag before i'd have used it.

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Tue 19 Oct 2004 10:00 PM (UTC)
Message
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.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #8 on Wed 20 Oct 2004 01:56 AM (UTC)
Message
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

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

Posted by Mirrodan   USA  (28 posts)  Bio
Date Reply #9 on Wed 20 Oct 2004 10:43 AM (UTC)
Message
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

Admin and Head Coder
For Techno-Magicka
techno-magicka.dreasphere.org 4000
AIM: tchnmgck
MSN: newell_everett@hotmail.com
YAHOO: everettnewell
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,457 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.