I'm having problems trying to list the contents of a struc to the player. I currently have this:
if ( !str_cmp( arg1, "list" ) )
{
for ( i = 0; i < MAX_SMITH_ITEMS; i++ )
{
pager_printf( ch, "Item: %s, Increment: %d\n\r", smith_items_table->name, i );
}
return;
}
Fist few lines of the struc;
const struct smith_items_type smith_items_table [] =
{
{ 0, "NULL", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "NULL" }, /* 0 */
{ 1, "knife", 10, 10, 10, 5, ITEM_TAKE|ITEM_WIELD, ITEM_WEAPON, 0, 1, 4, 0, 0, 0, 0, 0, "pierce" }, /* 1 */
{ 2, "cock-spur", 5, 5, 10, 4, ITEM_TAKE|ITEM_WIELD, ITEM_WEAPON, 0, 1, 3, 0, 0, 0, 0, 0, "pierce" }, /* 2 */
{ 3, "stiletto", 12, 10, 15, 5, ITEM_TAKE|ITEM_WIELD, ITEM_WEAPON, 0, 1, 5, 0, 0, 0, 0, 0, "stab" }, /* 3 */
{ 4, "dagger", 15, 10, 20, 30, ITEM_TAKE|ITEM_WIELD, ITEM_WEAPON, 12, 1, 6, 2, 0, 0, 0, 0, "pierce" }, /* 4 */
And this is the output I get when I do 'forge list'
Item: NULL, Increment: 0
Item: NULL, Increment: 1
Item: NULL, Increment: 2
Item: NULL, Increment: 3
Item: NULL, Increment: 4
Item: NULL, Increment: 5
Item: NULL, Increment: 6
Item: NULL, Increment: 7
Item: NULL, Increment: 8
Item: NULL, Increment: 9
Item: NULL, Increment: 10
Item: NULL, Increment: 11
Item: NULL, Increment: 12
Item: NULL, Increment: 13
Item: NULL, Increment: 14
Item: NULL, Increment: 15
I think I see the problem but not sure how to solve it. It's not actually checking the each row of the struc. Its only checking the first line. I did original have;
pager_printf( ch, "Item: %s, Increment: %d\n\r", smith_items_table[i].name, i );
That just crashes the mud upon 'forge list'.
Where am I going wrong? Am I simply trying to access the data incorrectly? Any help would be very much appreciated. |