From 65cfd3242f14e27cad67440410783560dcea3656 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Mar 2015 20:56:40 +0300 Subject: Add function menustr. It works same with menuint but return string and set variable @menuret$ --- npc/functions/input.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'npc/functions/input.txt') diff --git a/npc/functions/input.txt b/npc/functions/input.txt index f71b7ae7..62c53fd1 100644 --- a/npc/functions/input.txt +++ b/npc/functions/input.txt @@ -34,3 +34,32 @@ function script menuint { @menuret = .@vals[@menu]; return @menuret; } + +function script menustr { + 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 ""; + + @menu --; + if (@menu < 0 || @menu >= getarraysize(.@vals$)) + return ""; + + @menuret$ = .@vals$[@menu]; + return @menuret$; +} -- cgit v1.2.3-70-g09d2