From 0b4156877e7e47edb1233b3bca3aa33dca5346f8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Mar 2015 14:00:56 +0300 Subject: Add function menu2 for return some missing features. Example: menu2 "test 1", 10, "test 2", 20; If select "test 1", will set @menuret to 10, and @menu to 1 If select "test 2", will set @menuret to 20, and @menu to 2 --- npc/000-2-1/alige.txt | 2 +- npc/001-2-22/alige.txt | 2 +- npc/functions/input.txt | 36 ++++++++++++++++++++++++++++++++++++ npc/scripts.conf | 1 + 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 npc/functions/input.txt diff --git a/npc/000-2-1/alige.txt b/npc/000-2-1/alige.txt index 39d88b3c..34fc7912 100644 --- a/npc/000-2-1/alige.txt +++ b/npc/000-2-1/alige.txt @@ -167,7 +167,7 @@ L_Accepted: L_GiveFood: mes ""; - menu + menu2 rif(countitemcolor(501, 1), l(getitemname("Acorn"))), 0, rif(countitemcolor(502, 1), l(getitemname("Bread"))), 502, rif(countitemcolor(503, 1), l(getitemname("Fungus"))), 503, diff --git a/npc/001-2-22/alige.txt b/npc/001-2-22/alige.txt index 24db2387..a003f252 100644 --- a/npc/001-2-22/alige.txt +++ b/npc/001-2-22/alige.txt @@ -171,7 +171,7 @@ L_Accepted: L_GiveFood: mes ""; - menu + menu2 rif(countitemcolor(501, 1), l(getitemname("Acorn"))), 0, rif(countitemcolor(502, 1), l(getitemname("Bread"))), 502, rif(countitemcolor(503, 1), l(getitemname("Fungus"))), 503, diff --git a/npc/functions/input.txt b/npc/functions/input.txt new file mode 100644 index 00000000..c380940c --- /dev/null +++ b/npc/functions/input.txt @@ -0,0 +1,36 @@ +// Evol functions. +// Authors: +// 4144 +// Description: +// Input utility functions +// Variables: +// none + +function script menu2 { + deletearray .@vals; + .@menustr$ = ""; + .@cnt = 0; + + for (.@f = 0; .@f < getargcount(); .@f = .@f + 2) + { + if (getarg(.@f) != "") + { + .@menustr$ = .@menustr$ + getarg(.@f) + ":"; + .@vals[.@cnt] = getarg(.@f + 1); + .@cnt ++; + } + } + + @menu = 255; + @menuret = -1; + select(.@menustr$); + if (@menu == 255) + return -1; + + @menu --; + if (@menu < 0 || @menu >= getarraysize(.@vals)) + return -1; + + @menuret = .@vals[@menu]; + return @menuret; +} diff --git a/npc/scripts.conf b/npc/scripts.conf index eeb92856..c5b3a457 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -10,6 +10,7 @@ npc: npc/functions/clientversion.txt npc: npc/functions/doors.txt npc: npc/functions/hammocks.txt npc: npc/functions/harbours.txt +npc: npc/functions/input.txt npc: npc/functions/inventoryplace.txt npc: npc/functions/goodbye.txt npc: npc/functions/sailordialogue.txt -- cgit v1.2.3-70-g09d2