Welcome to the Builder Academy

Question Adding New Zedit String

More
12 Oct 2012 00:04 #882 by Liko
Adding New Zedit String was created by Liko
Hello,

This time I'm asking for help on adding a new zedit string load/save. Mainly what files and functions that would need to be edited.

Here is an exmple:

Planet: <whatever builder types in zedit>
Then get it to save and load.

Thanks.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
12 Oct 2012 01:10 #883 by Gahan
Replied by Gahan on topic Re: Adding New Zedit String
Yeah, zedit.c

Search for the static function zedit_disp_menu, scroll down to where you see the items displayed, and add your stuff in there.

Then you're going to have to add a new variable, OLC_ZONE(d)->planet_name, in order for the send_to_char to work, which is going to require you to make an addition for the zone_data in db.c struct zone_data, possibly something to the effect of char *planetname; in the struct.

Now, in order for the mud to not hang when you're doing this, you're going to have to add a connectedness state to oasis.h, in the zedit connectedness defined macro list something like
#define ZEDIT_ZONE_PLANETNAME <next number> (dont forget to update the MAX_ZEDIT_ZONE if there is one, i'm doing this from memory so I apologize.

What else... OH yeah, the saving and loading:

in genzon.c in the create_new_zone function, you're going to add a new struct member for planetname so it reserves a spot for the new property.

also in genzon.c in the save_zone function, add some code to make sure the zone gets written to file properly, something like this should do:

/* Print zone header to file. */
fprintf(zfile, "#%d\n"
"%s~\n"
"%s~\n"
++ "%s~\n"
"%hd %hd %d %d %d %d\n",
zone_table[zone_num].number,
(zone_table[zone_num].name && *zone_table[zone_num].name) ? zone_table [zone_num].name : "undefined",
(zone_table[zone_num].builders && *zone_table[zone_num].builders) ? zone_table[zone_num].builders : "None."
++ (zone_table[zone_num].builder && *zone_table[zon_num].planetname) ? zone_table[zone_num].planetname : "None."
genolc_zone_bottom(zone_num),
zone_table[zone_num].top,
zone_table[zone_num].lifespan,
zone_table[zone_num].reset_mode,
zone_table[zone_num].min_level,
zone_table[zone_num].max_level
);

Update the 2nd part of the function as well, the one that checks for types of zone files

to LOAD go to db.c and go to the load_zones function, you will see something like:

line_num += get_line(fl, buf);
if ((ptr = strchr(buf, '~')) != NULL) /* take off the '~' if it's there */
*ptr = '\0';
Z.builders = strdup(buf);

Duplicate this for your planetname info.

To be able to edit this from zedit, you're going to have to add a new part to ZEDIT_MAIN_MENU for the new setting, and a new ZEDIT_ZONE_PLANETNAME case to display your new mini-menu for inputting the name of the zone to zedit_parse function.

Its a relatively complicated task for people not too familiar with modifying OLC. Let me know if you run into trouble :)

Hope this helps

Please Log in or Create an account to join the conversation.

More
12 Oct 2012 02:48 #884 by Vatiken
Replied by Vatiken on topic Re: Adding New Zedit String

Gahan wrote: ...
Hope this helps

+1

tbaMUD developer/programmer

Please Log in or Create an account to join the conversation.

More
12 Oct 2012 20:09 #887 by Liko
Replied by Liko on topic Re: Adding New Zedit String

Vatiken wrote:

Gahan wrote: ...
Hope this helps

+1


*Points* It's a ghost, it's a ghost. I spotted a ghost these days!

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
12 Oct 2012 22:34 #888 by Liko
Replied by Liko on topic Re: Adding New Zedit String
So far the only issue I'm running into is that it's not saving after I leave zedit.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
13 Oct 2012 18:22 #890 by Liko
Replied by Liko on topic Re: Adding New Zedit String
Well since I know it's not saving. I know it's with save_zone in genzon.c

Here is the first part where I adding planet_name for saving
Code:
if (flag_tot == 0 && zone_table[zone_num].min_level == -1 && zone_table[zone_num].max_level == -1) { /* Print zone header to file. */ fprintf(zfile, "#%d\n" "%s~\n" "%s~\n" "%s~\n" "%d %d %d %d\n", zone_table[zone_num].number, (zone_table[zone_num].builders && *zone_table[zone_num].builders) ? zone_table[zone_num].builders : "None.", (zone_table[zone_num].name && *zone_table[zone_num].name) ? convert_from_tabs(zone_table[zone_num].name) : "undefined", (zone_table[zone_num].planet_name && *zone_table[zone_num].planet_name) ? zone_table[zone_num].planet_name : "None.", genolc_zone_bottom(zone_num), zone_table[zone_num].top, zone_table[zone_num].lifespan, zone_table[zone_num].reset_mode );

I believe everything above looks correct.

Here is the second part.
Code:
/* Print zone header to file. */ fprintf(zfile, "#%d\n" "%s~\n" "%s~\n" "%s~\n" "%d %d %d %d %s %s %s %s %d %d\n", /* New tbaMUD data line */ zone_table[zone_num].number, (zone_table[zone_num].builders && *zone_table[zone_num].builders) ? zone_table[zone_num].builders : "None.", (zone_table[zone_num].name && *zone_table[zone_num].name) ? convert_from_tabs(zone_table[zone_num].name) : "undefined", (zone_table[zone_num].planet_name && *zone_table[zone_num].planet_name) ? zone_table[zone_num].planet_name : "None.", genolc_zone_bottom(zone_num), zone_table[zone_num].top, zone_table[zone_num].lifespan, zone_table[zone_num].reset_mode, zbuf1, zbuf2, zbuf3, zbuf4, zone_table[zone_num].min_level, zone_table[zone_num].max_level ); }

That is all for save_zone.

Any suggestions?

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

Time to create page: 0.873 seconds