summaryrefslogtreecommitdiff
path: root/npc/functions/input.txt
blob: cf0382d25fae89b4262c1435190ae8f6d95deaa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Evol functions.
// Author:
//    4144
// Description:
//    Input utility functions
// Variables:
//    none

function	script	menuint	{
    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 ++;
        }
    }

    .@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;
}

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$;
}