diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-07-31 13:26:38 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-07-31 13:26:38 -0300 |
commit | bdb40f4c49f32b0145d5127b2071fa3bc92c8e1b (patch) | |
tree | 9a4c3aafa61af07bf8e960a832a869271b2ecbbc /npc/functions | |
parent | 70c2ecc2c4b58e4427f5e3f40b6f8d6528a50302 (diff) | |
download | serverdata-bdb40f4c49f32b0145d5127b2071fa3bc92c8e1b.tar.gz serverdata-bdb40f4c49f32b0145d5127b2071fa3bc92c8e1b.tar.bz2 serverdata-bdb40f4c49f32b0145d5127b2071fa3bc92c8e1b.tar.xz serverdata-bdb40f4c49f32b0145d5127b2071fa3bc92c8e1b.zip |
Bugfixes to menuint2
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/input.txt | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/npc/functions/input.txt b/npc/functions/input.txt index 1bce63792..0a510b740 100644 --- a/npc/functions/input.txt +++ b/npc/functions/input.txt @@ -68,38 +68,40 @@ function script menustr { // menuint2(<array>) function script menuint2 { - .@ar$=getarg(0); - .@vals=0; .@menustr$=""; - if (!(getdatatype(.@ar$) & DATATYPE_VAR)) - Exception("Inadequate argument type", RB_DEFAULT|RB_ISFATAL); + if (!(getdatatype(getarg(0)) & DATATYPE_VAR)) + Exception("Inadequate argument type - Must be var", RB_DEFAULT|RB_ISFATAL); + + copyarray(.@ar$, getarg(0), getarraysize(getarg(0))); if (getarraysize(.@ar$) % 2 != 0) - Exception("Invalid array size", RB_DEFAULT|RB_ISFATAL); + Exception("Invalid array size: "+getarraysize(.@ar$), RB_DEFAULT|RB_ISFATAL); freeloop(true); for (.@f=0; .@f < getarraysize(.@ar$); .@f++) { // String vs Int if (.@f % 2 == 0) { - .@menustr$+=getd(.@ar$+"["+.@f+"]")+":"; + .@menustr$+=.@ar$[.@f]+":"; } else { - array_push(.@vals, getd(.@ar$+"["+.@f+"]")); + array_push(.@vals, atoi(.@ar$[.@f])); } } freeloop(false); // Do the request // We have: .@vals and .@menustr$ - .@vals[.@cnt] = -1; @menu = 255; @menuret = -1; select(.@menustr$); + //debugmes "Option %d", @menu; + //debugmes "Array size %d", getarraysize(.@vals); + if (@menu == 255) return -1; - @menu --; - if (@menu < 0 || @menu >= getarraysize(.@vals) - 1) + @menu-=1; + if (@menu < 0 || @menu > getarraysize(.@vals) - 1) return -1; @menuret = .@vals[@menu]; |