From 0cde61e44137623f883b22f682bff9be0c29bfcf Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Mon, 4 Apr 2022 14:42:20 -0300 Subject: Chronos the shopkeeper, with evil edits from The Mana World Team. --- world/map/npc/functions/item_menu.txt | 296 ++++++++++++++++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 world/map/npc/functions/item_menu.txt (limited to 'world/map/npc/functions') diff --git a/world/map/npc/functions/item_menu.txt b/world/map/npc/functions/item_menu.txt new file mode 100644 index 00000000..a14f1fba --- /dev/null +++ b/world/map/npc/functions/item_menu.txt @@ -0,0 +1,296 @@ +// Input: @items (array of items you want to choose from) +// @item_names$ (names of the items in @items) +// @default_choice$ (default option) +// Return: @item (The selected item, or 0 if the default/something invalid was chosen) +// +// NOTE: ItemMenu is ONLY used for scripts that need to do math with @item like tailor, dyer, bleacher +// All other scripts should use ItemMenu$ + +function|script|ItemMenu +{ +set @items_nr, getarraysize(@items); +if(@items_nr != getarraysize(@item_names$)) goto L_ArrayLengthMismatch; +if(@default_choice$ == "") set @default_choice$, "Never mind."; +goto L_pick_one_of_many_items; + +L_pick_one_of_many_items: + set @c, 0; + + setarray @choice_n$, "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", ""; + goto L_pick_choice_loop; + +L_pick_choice_loop: + if (@c >= @items_nr) + goto L_choice_init_done; + set @choice_v[@c], @items[@c]; + set @choice_n$[@c], @item_names$[@c]; + set @choice_i[@c], @c; + set @c, @c + 1; + goto L_pick_choice_loop; + +L_choice_init_done: + set @choice_v[@c], 0; + set @choice_n$[@c], @default_choice$; + set @c, @c + 1; + + if (@c < 10) + menu + @choice_n$[0], L_MenuItems, + @choice_n$[1], L_MenuItems, + @choice_n$[2], L_MenuItems, + @choice_n$[3], L_MenuItems, + @choice_n$[4], L_MenuItems, + @choice_n$[5], L_MenuItems, + @choice_n$[6], L_MenuItems, + @choice_n$[7], L_MenuItems, + @choice_n$[8], L_MenuItems, + @choice_n$[9], L_MenuItems; + goto L_MenuItems; + +L_MenuItems: + if (@c < 10) + goto L_choice_join; + + if (@c < 20) + menu + @choice_n$[0], L_MenuItems1, + @choice_n$[1], L_MenuItems1, + @choice_n$[2], L_MenuItems1, + @choice_n$[3], L_MenuItems1, + @choice_n$[4], L_MenuItems1, + @choice_n$[5], L_MenuItems1, + @choice_n$[6], L_MenuItems1, + @choice_n$[7], L_MenuItems1, + @choice_n$[8], L_MenuItems1, + @choice_n$[9], L_MenuItems1, + @choice_n$[10], L_MenuItems1, + @choice_n$[11], L_MenuItems1, + @choice_n$[12], L_MenuItems1, + @choice_n$[13], L_MenuItems1, + @choice_n$[14], L_MenuItems1, + @choice_n$[15], L_MenuItems1, + @choice_n$[16], L_MenuItems1, + @choice_n$[17], L_MenuItems1, + @choice_n$[18], L_MenuItems1, + @choice_n$[19], L_MenuItems1; + goto L_MenuItems1; + +L_MenuItems1: + if (@c < 20) + goto L_choice_join; + + menu + @choice_n$[0], L_choice_join, + @choice_n$[1], L_choice_join, + @choice_n$[2], L_choice_join, + @choice_n$[3], L_choice_join, + @choice_n$[4], L_choice_join, + @choice_n$[5], L_choice_join, + @choice_n$[6], L_choice_join, + @choice_n$[7], L_choice_join, + @choice_n$[8], L_choice_join, + @choice_n$[9], L_choice_join, + @choice_n$[10], L_choice_join, + @choice_n$[11], L_choice_join, + @choice_n$[12], L_choice_join, + @choice_n$[13], L_choice_join, + @choice_n$[14], L_choice_join, + @choice_n$[15], L_choice_join, + @choice_n$[16], L_choice_join, + @choice_n$[17], L_choice_join, + @choice_n$[18], L_choice_join, + @choice_n$[19], L_choice_join, + @choice_n$[20], L_choice_join, + @choice_n$[21], L_choice_join, + @choice_n$[22], L_choice_join, + @choice_n$[23], L_choice_join, + @choice_n$[24], L_choice_join, + @choice_n$[25], L_choice_join, + @choice_n$[26], L_choice_join, + @choice_n$[27], L_choice_join, + @choice_n$[28], L_choice_join, + @choice_n$[29], L_choice_join, + @choice_n$[30], L_choice_join, + @choice_n$[31], L_choice_join, + @choice_n$[32], L_choice_join, + @choice_n$[33], L_choice_join, + @choice_n$[34], L_choice_join, + @choice_n$[35], L_choice_join, + @choice_n$[36], L_choice_join, + @choice_n$[37], L_choice_join, + @choice_n$[38], L_choice_join, + @choice_n$[39], L_choice_join; + +L_choice_join: + set @menu, @menu - 1; + set @item, @choice_v[@menu]; + set @index, @choice_i[@menu]; + if (@menu >= @c) + set @item, 0; + goto L_Clean; + +L_Clean: + set @menu, 0; + set @items_nr, 0; + set @c, 0; + cleararray @choice_v, 0, getarraysize(@choice_v); + cleararray @choice_n$, "", getarraysize(@choice_n$); + cleararray @choice_i, 0, getarraysize(@choice_i); + return; + +L_ArrayLengthMismatch: + debugmes "@items and @item_names$ array length mismatch"; + mapexit; +} + + + + +// Input: @items$ (array of items you want to choose from) +// @item_names$ (names of the items in @items) +// @default_choice$ (default option) +// Return: @item$ (The selected item, or 0 if the default/something invalid was chosen) + +function|script|ItemMenu$ +{ +set @items_nr, getarraysize(@items$); +if(@items_nr != getarraysize(@item_names$)) goto L_ArrayLengthMismatch; +if(@default_choice$ == "") set @default_choice$, "Never mind."; +goto L_pick_one_of_many_items; + +L_pick_one_of_many_items: + set @c, 0; + + setarray @choice_n$, "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", ""; + goto L_pick_choice_loop; + +L_pick_choice_loop: + if (@c >= @items_nr) + goto L_choice_init_done; + set @choice_v$[@c], @items$[@c]; + set @choice_n$[@c], @item_names$[@c]; + set @choice_i[@c], @c; + set @c, @c + 1; + goto L_pick_choice_loop; + +L_choice_init_done: + set @choice_v$[@c], ""; + set @choice_n$[@c], @default_choice$; + set @c, @c + 1; + + if (@c < 10) + menu + @choice_n$[0], L_MenuItems, + @choice_n$[1], L_MenuItems, + @choice_n$[2], L_MenuItems, + @choice_n$[3], L_MenuItems, + @choice_n$[4], L_MenuItems, + @choice_n$[5], L_MenuItems, + @choice_n$[6], L_MenuItems, + @choice_n$[7], L_MenuItems, + @choice_n$[8], L_MenuItems, + @choice_n$[9], L_MenuItems; + goto L_MenuItems; + +L_MenuItems: + if (@c < 10) + goto L_choice_join; + + if (@c < 20) + menu + @choice_n$[0], L_MenuItems1, + @choice_n$[1], L_MenuItems1, + @choice_n$[2], L_MenuItems1, + @choice_n$[3], L_MenuItems1, + @choice_n$[4], L_MenuItems1, + @choice_n$[5], L_MenuItems1, + @choice_n$[6], L_MenuItems1, + @choice_n$[7], L_MenuItems1, + @choice_n$[8], L_MenuItems1, + @choice_n$[9], L_MenuItems1, + @choice_n$[10], L_MenuItems1, + @choice_n$[11], L_MenuItems1, + @choice_n$[12], L_MenuItems1, + @choice_n$[13], L_MenuItems1, + @choice_n$[14], L_MenuItems1, + @choice_n$[15], L_MenuItems1, + @choice_n$[16], L_MenuItems1, + @choice_n$[17], L_MenuItems1, + @choice_n$[18], L_MenuItems1, + @choice_n$[19], L_MenuItems1; + goto L_MenuItems1; + +L_MenuItems1: + if (@c < 20) + goto L_choice_join; + + menu + @choice_n$[0], L_choice_join, + @choice_n$[1], L_choice_join, + @choice_n$[2], L_choice_join, + @choice_n$[3], L_choice_join, + @choice_n$[4], L_choice_join, + @choice_n$[5], L_choice_join, + @choice_n$[6], L_choice_join, + @choice_n$[7], L_choice_join, + @choice_n$[8], L_choice_join, + @choice_n$[9], L_choice_join, + @choice_n$[10], L_choice_join, + @choice_n$[11], L_choice_join, + @choice_n$[12], L_choice_join, + @choice_n$[13], L_choice_join, + @choice_n$[14], L_choice_join, + @choice_n$[15], L_choice_join, + @choice_n$[16], L_choice_join, + @choice_n$[17], L_choice_join, + @choice_n$[18], L_choice_join, + @choice_n$[19], L_choice_join, + @choice_n$[20], L_choice_join, + @choice_n$[21], L_choice_join, + @choice_n$[22], L_choice_join, + @choice_n$[23], L_choice_join, + @choice_n$[24], L_choice_join, + @choice_n$[25], L_choice_join, + @choice_n$[26], L_choice_join, + @choice_n$[27], L_choice_join, + @choice_n$[28], L_choice_join, + @choice_n$[29], L_choice_join, + @choice_n$[30], L_choice_join, + @choice_n$[31], L_choice_join, + @choice_n$[32], L_choice_join, + @choice_n$[33], L_choice_join, + @choice_n$[34], L_choice_join, + @choice_n$[35], L_choice_join, + @choice_n$[36], L_choice_join, + @choice_n$[37], L_choice_join, + @choice_n$[38], L_choice_join, + @choice_n$[39], L_choice_join; + +L_choice_join: + set @menu, @menu - 1; + set @item$, @choice_v$[@menu]; + set @index, @choice_i[@menu]; + if (@menu >= @c) + set @item$, ""; + goto L_Clean; + +L_Clean: + set @menu, 0; + set @items_nr, 0; + set @c, 0; + cleararray @choice_v$, "", getarraysize(@choice_v$); + cleararray @choice_n$, "", getarraysize(@choice_n$); + cleararray @choice_i, 0, getarraysize(@choice_i); + return; + +L_ArrayLengthMismatch: + debugmes "@items$ and @item_names$ array length mismatch"; + mapexit; +} -- cgit v1.2.3-70-g09d2