Better support for tables in ShowMenu

Issue #51 closed
Chimaine created an issue

Currently ShowMenu always returns a 0-based index of the choice made. This is convenient for the compiler but not for the user.

Two steps to make the direct use of this function for users easier:

  • Return a 1-based index on varargs options
  • Return the value at the chosen index if given a table.

Currently, an example have to be written like this

reactions = { "friendly", "neutral", "hostile", "scared" };
reaction = reactions[ShowMenu( "Choose a reaction", reactions ) + 1];

With the above changes, this would become

reaction = ShowMenu( "Choose a reaction", { "friendly", "neutral", "hostile", "scared" } );

No changes in the usage of menu should be needed.

Comments (2)

  1. Log in to comment