menu cannot handle item list

This section is for the reporting of bugs or any sort of issues found during testing. It is also used for the organisation of contributors in general.


Post Reply
User avatar
quietlyquietly
Novice
Novice
Posts: 52
Joined: 07 Sep 2023, 09:40

menu cannot handle item list

Post by quietlyquietly »

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;
User avatar
Bjørn
Manasource
Manasource
Posts: 1482
Joined: 09 Dec 2004, 18:50
Location: North Rhine-Westphalia, Germany
Contact:

Re: menu cannot handle item list

Post by Bjørn »

I think the solution is basically just to revert this removal of getitemname:

https://git.themanaworld.org/tmw/tmwa/- ... a69edf5d4f

User avatar
quietlyquietly
Novice
Novice
Posts: 52
Joined: 07 Sep 2023, 09:40

Re: menu cannot handle item list

Post by quietlyquietly »

I can not figure out why functions have been removed, just because they were not being currently used ?
If they were not being used, they were not bothering anyone.

What really is needed:

  1. Make menu command not choke on seeing color change syntax in its menu string.

  2. Make menu command notice that the operand is an array, and display in the menu all the elements of the array, up to the first empty element.
    This will be needed anyways because any function for doing dynamic menus is so much of a kludge otherwise.

  3. Better support functionality, like many of the missing functions. Too much work around code requires loops that have to be done in tedious hand code. This is resulting in slow script execution which is going to compound into being more of a problem later. The script engine can only do about 150 instructions before it dies with an "infinite loop" error message, and that is not enough for many of the functions I am needing.

  4. Get rid of the no-label-fallthrough test for common code. Such a thing was only be important for OnInit or OnTime code blocks, where probably it should not fall into the next code block. If this requires a special instruction for skip-over-lable-here, then it should be included automatically.

Post Reply