Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_heart_player_response_shop_Step_0

(view raw script w/o annotations or w/e)
1
var player_gold = global.player_gold
2
var buy_shop_screen_number = global.buy_shop_screen_number
3
script_execute(gml_Script_scr_controls_shop_response)
4
if key_select
5
{
6
    if (response_shop_screen_number == 1)
7
    {
8
        if (player_gold < global.shop_gold_requirement[buy_shop_screen_number])
9
        {
10
            global.player_response = 1
11
            global.able_to_buy = 1
12
            audio_play_sound(snd_fail, 1, 0)
13
        }
14
        else if (global.item_slot[8] != "Nothing")
15
        {
16
            global.player_response = 1
17
            global.able_to_buy = 2
18
            audio_play_sound(snd_fail, 1, 0)
19
        }
20
        else
21
        {
22
            global.player_response = 1
23
            global.able_to_buy = 0
24
            var i = 1
25
            while (i <= 8)
26
            {
27
                if (global.item_slot[i] == "Nothing")
28
                {
29
                    global.item_slot[i] = global.shop_item[buy_shop_screen_number]
30
                    global.player_gold -= global.shop_gold_requirement[buy_shop_screen_number]
31
                    break
32
                }
33
                else
34
                {
35
                    i += 1
36
                    continue
37
                }
38
            }
39
            audio_play_sound(snd_shop_purchase, 20, false)
40
        }
41
        event_user(0)
42
        return;
43
    }
44
    else if (response_shop_screen_number == 2)
45
    {
46
        global.player_response = 2
47
        event_user(0)
48
        return;
49
    }
50
}
51
if (key_revert && key_select == 0)
52
{
53
    global.player_response = 2
54
    event_user(0)
55
    return;
56
}
57
if (key_select == 0 && key_revert == 0)
58
{
59
    if (key_down && key_up == 0)
60
    {
61
        if (response_shop_screen_number == 2)
62
            response_shop_screen_number = 1
63
        else
64
            response_shop_screen_number += 1
65
    }
66
    if (key_up && key_down == 0)
67
    {
68
        if (response_shop_screen_number == 1)
69
            response_shop_screen_number = 2
70
        else
71
            response_shop_screen_number -= 1
72
    }
73
}
74
if (response_shop_screen_number == 1)
75
{
76
    x = obj_main_screen_shop.x + 229
77
    y = obj_main_screen_shop.y + 59
78
}
79
else if (response_shop_screen_number == 2)
80
{
81
    x = obj_main_screen_shop.x + 229
82
    y = obj_main_screen_shop.y + 74
83
}