Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_codeentry_Step_0

(view raw script w/o annotations or w/e)
1
if (con == 0)
2
{
3
    timer++;
4
    if (left_p())
5
    {
6
        snd_play_pitch(snd_menumove, 0.9);
7
        mpos--;
8
    }
9
    if (right_p())
10
    {
11
        snd_play_pitch(snd_menumove, 1);
12
        mpos++;
13
    }
14
    if (mpos == numcount)
15
        mpos = 0;
16
    if (mpos < 0)
17
        mpos = numcount - 1;
18
    if (down_h())
19
        dholdbuff++;
20
    else
21
        dholdbuff = -1;
22
    if (up_h())
23
        uholdbuff++;
24
    else
25
        uholdbuff = -1;
26
    if (up_h() && down_h())
27
    {
28
        dholdbuff = -1;
29
        uholdbuff = -1;
30
    }
31
    buffmodrate = 5;
32
    if ((uholdbuff % buffmodrate) == 0)
33
    {
34
        snd_play_pitch(snd_menumove, 1);
35
        num[mpos]++;
36
    }
37
    else if ((dholdbuff % buffmodrate) == 0)
38
    {
39
        snd_play_pitch(snd_menumove, 0.9);
40
        num[mpos]--;
41
    }
42
    if (num[mpos] > maxnum)
43
        num[mpos] = 0;
44
    if (num[mpos] < 0)
45
        num[mpos] = maxnum;
46
    if (button1_p())
47
    {
48
        snd_play_pitch(snd_menumove, 1.2);
49
        con = 1;
50
        timer = 0;
51
    }
52
    if (button2_p() && !noquit)
53
    {
54
        snd_play_pitch(snd_menumove, 0.8);
55
        con = 1;
56
        result = -2;
57
        timer = 31;
58
        debug_message("entrystring=" + entrystring);
59
    }
60
}
61
if (con == 1)
62
{
63
    timer++;
64
    if (timer == 30)
65
    {
66
        var wrong = false;
67
        for (var i = 0; i < numcount; i++)
68
        {
69
            if (correctcode[i] != num[i])
70
                wrong = true;
71
            entrystring += string(num[i]);
72
        }
73
        debug_message("entrystring=" + entrystring);
74
        if (wrong == true)
75
        {
76
            snd_play(snd_error);
77
            txtcolor = 255;
78
        }
79
        else
80
        {
81
            snd_play(snd_bell);
82
            txtcolor = 65535;
83
        }
84
        result = 1 - wrong;
85
    }
86
}