Uploaded: 06 Nov, 2013
Previous uploads by this submitter: 0

Author: Davion

Downloads: 21

This allows you to display a bunch of stuff in a grid. It's useful for easily setting up formatted scores. A basic example follows below.
A few things about this. When you create a grid you set a width. This width is usually +1. If you never want more then 80, you should use 79. For internal cell widths, the size is the space it takes up, include the padding and a single character for the border. So create_cell(row,30), will give you a 30 character cell, but only 25 characters will be displayed with 2 space padding and the 1 border character. When creating the row, the internal cell widths must SUM the width of the grid.

Requires printf_to_char, and accounts for colourcodes prefixed with {.

void do_score (CHAR_DATA * ch, char *argument)
int i;
GRID_DATA *grid;
GRID_ROW *row;
GRID_CELL *cell;
grid = create_grid(75);
row = create_row(grid);
row_append_cell(row, 35, "%s%s\nLevel: %d\n%d years old\n%d hours",
IS_NPC (ch) ? "" : ch->pcdata->title,
ch->level, get_age (ch),
(ch->played + (int) (current_time - ch->logon)) / 3600);

row_append_cell(row, 20, "Race: %s\nSex: %s\nClass: %s",
ch->sex == 0 ? "sexless" : ch->sex == 1 ? "male" : "female",
IS_NPC (ch) ? "mobile" : class_table[ch->class].name);

row_append_cell(row, 20,
"HP: %d/%d\nMana: %d/%d\nMove: %d/%d",
ch->hit, ch->max_hit,
ch->mana, ch->max_mana, ch->move, ch->max_move);

row = create_row(grid);
row_append_cell(row, 30,"You are trusted at level %d", get_trust (ch));
row_append_cell(row, 45,"You have %d practices and %d trains.", ch->practice, ch->train);

row = create_row(grid);

//Capture the cell to add a conditional row to the cell.
cell = row_append_cell(row, 58,
"Carrying %d/%d items, weighing %ld/%d pounds.\nScoring %d exp, and have %ld gold and %ld silver coins.",
ch->carry_number, can_carry_n (ch),
get_carry_weight (ch) / 10, can_carry_w (ch) / 10,
ch->exp, ch->gold, ch->silver);
/* RT shows exp to level */
if (!IS_NPC (ch) && ch->level < LEVEL_HERO)
"\nYou need %d exp to level",
((ch->level + 1) * exp_per_level (ch, ch->pcdata->points) -

cell_append_contents(cell, "\nWimpy set to %d hit points.", ch->wimpy);
row_append_cell(row, 17,
"Str: %d(%d)\nInt: %d(%d)\nWis: %d(%d)\nDex: %d(%d)\nCon: %d(%d)",
get_curr_stat (ch, STAT_STR),
get_curr_stat (ch, STAT_INT),
get_curr_stat (ch, STAT_WIS),
get_curr_stat (ch, STAT_DEX),
ch->perm_stat[STAT_CON], get_curr_stat (ch, STAT_CON));
grid_to_char (grid, ch, TRUE );

if (IS_SET (ch->comm, COMM_SHOW_AFFECTS))
do_function (ch, &do_affects, "");