summaryrefslogtreecommitdiff
path: root/npc/functions/input.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/input.txt')
-rw-r--r--npc/functions/input.txt39
1 files changed, 39 insertions, 0 deletions
diff --git a/npc/functions/input.txt b/npc/functions/input.txt
index cf0382d25..1ccfc0578 100644
--- a/npc/functions/input.txt
+++ b/npc/functions/input.txt
@@ -1,6 +1,7 @@
// Evol functions.
// Author:
// 4144
+// Jesusalva
// Description:
// Input utility functions
// Variables:
@@ -64,3 +65,41 @@ function script menustr {
@menuret$ = .@vals$[@menu];
return @menuret$;
}
+
+// menuint2(<array>)
+function script menuint2 {
+ .@ar$=getarg(0);
+ .@vals=0;
+ .@menustr$="";
+
+ if (getarraysize(.@ar$) % 2 != 0)
+ Exception("Invalid array size", RB_DEFAULT|RB_ISFATAL);
+
+ freeloop(true);
+ for (.@f=0; .@f < getarraysize(.@ar$); .@f++) {
+ // String vs Int
+ if (.@f % 2 == 0) {
+ .@menustr$+=getd(.@ar$+"["+.@f+"]")+":";
+ } else {
+ array_push(.@vals, getd(.@ar$+"["+.@f+"]"));
+ }
+ }
+ freeloop(false);
+
+ // Do the request
+ // We have: .@vals and .@menustr$
+ .@vals[.@cnt] = -1;
+ @menu = 255;
+ @menuret = -1;
+ select(.@menustr$);
+ if (@menu == 255)
+ return -1;
+
+ @menu --;
+ if (@menu < 0 || @menu >= getarraysize(.@vals) - 1)
+ return -1;
+
+ @menuret = .@vals[@menu];
+ return @menuret;
+}
+