menu cannot handle item list
I am working on scripts for tmwAthena, which need to ask players to select an item from a list. This occurs in multiple places.
The problem is that the item names come from getiteminfo, and they have this red color.
The menu cannot handle this, and has treated them as empty, or displays "@@" whereever in the menu string the item description appears.
Has anyone got a solution for how to put item names into dynamic menus ?
Is there another way to get an item name string, other than getiteminfo ?
Is there a way to sanitize the string from getiteminfo, to get a plain string ?
// Function to perform dynamic menu, displaying a list of items.
// I tried for 2 days to get that desc array to pass into this function, and could not get it
// to pass more than the first element.
Code: Select all
// Dynamic menu from desc array.
// Warning menu input will erase all .@var
// The getarg fails to pass the desc array, as it only gets the first element ( [0] ).
// Because of this, all menu desc array use @desc$.
function|script|dyn_menu_select
{
menu
@desc$[0],L_0,
@desc$[1],L_0,
@desc$[2],L_0,
@desc$[3],L_0,
@desc$[4],L_0,
@desc$[5],L_0,
@desc$[6],L_0,
@desc$[7],L_0,
@desc$[8],L_0,
@desc$[9],L_0,
@desc$[10],L_0,
@desc$[11],L_0,
@desc$[12],L_0,
@desc$[13],L_0,
@desc$[14],L_0,
@desc$[15],L_0,
@desc$[16],L_0,
@desc$[17],L_0,
@desc$[18],L_0,
@desc$[19],L_0,
@desc$[20],L_0,
@desc$[21],L_0,
@desc$[22],L_0,
@desc$[23],L_0,
@desc$[24],L_0,
@desc$[25],L_0,
@desc$[26],L_0,
@desc$[27],L_0,
@desc$[28],L_0,
@desc$[29],L_0,
@desc$[30],L_0,
@desc$[31],L_0,
@desc$[32],L_0;
L_0:
return @menu;
}
// Part of the code that fills in the @desc$.
// Putting the "#number" at the beginning of the string at least makes it display something.
Code: Select all
L_menu1:
set .@k, 0; // step by 3
set .@w, 0;
goto L_menu_loop1;
L_menu_loop1:
// To form menu desc.
set .@s$, getitemlink(.@ig[.@k]);
if( .@s$ == "Unknown Item" ) goto L_menu_nxt1;
// The getitemlink string has a red color that is incompatible
// with the menu operation.
set .@n0$, .@ig[.@k];
set @desc$[.@w], "#"+.@n0$+" : "+.@s$+" ";
set .@w, .@w+1;
goto L_menu_nxt1;
L_menu_nxt1:
set .@k, .@k+3;
if( .@k < .@igz ) goto L_menu_loop1;
goto L_gat2;