Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_dunes_12_elevator_Step_0

(view raw script w/o annotations or w/e)
1
if (global.dunes_flag[4] < 2)
2
{
3
    if (keyboard_multicheck_pressed(0) && scr_interact
scr_interact

function scr_interact() { if (distance_to_object(obj_pl) < 20 && obj_pl.state == scr_normal_state) { var pl_dir = obj_pl.direction; var pl_x = 0; var pl_y = 0; var check_distance_x = 0; var check_distance_y = 0; switch (pl_dir) { case 0: pl_x = obj_pl.bbox_right; pl_y = obj_pl.bbox_top + 1; check_distance_x = 20; break; case 180: pl_x = obj_pl.bbox_left; pl_y = obj_pl.bbox_top + 1; check_distance_x = -20; break; case 90: pl_x = obj_pl.x; pl_y = obj_pl.bbox_top; check_distance_y = -20; break; case 270: pl_x = obj_pl.x; pl_y = obj_pl.bbox_bottom; check_distance_y = 20; break; } if (collision_line_first(pl_x, pl_y, pl_x + check_distance_x, pl_y + check_distance_y, id, false, false)) return true; } }
())
4
    {
5
        if (global.dunes_flag[4] == 0)
6
        {
7
            scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
8
            with (msg)
9
            {
10
                message[0] = "* (A piece of wood is lodged#  in-between the elevator doors.)";
11
                message[1] = "* (What could fix this poor#  elevator?)";
12
            }
13
            elevator_menu_open = true;
14
            global.dunes_flag[4] += 1;
15
        }
16
        else if (global.dunes_flag[4] == 1)
17
        {
18
            elevator_menu_open = true;
19
        }
20
    }
21
    if (!global.dialogue_open && elevator_menu_open == true)
22
    {
23
        instance_create(x, y, obj_item_use_menu);
24
        scr_cutscene_start
scr_cutscene_start

function scr_cutscene_start() { global.cutscene = true; obj_pl.state = scr_frozen_state; obj_pl.image_index = 0; obj_pl.image_speed = 0; }
();
25
        elevator_menu_open = false;
26
    }
27
    if (global.item_used_overworld != undefined)
28
    {
29
        scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
30
        with (msg)
31
        {
32
            switch (global.item_used_overworld)
33
            {
34
                default:
35
                    message[0] = "* (You can't think of a way to#  make this work.)";
36
                    global.cutscene = false;
37
                    break;
38
                case "Pickaxe":
39
                    message[0] = "* (You use the pickaxe to hack#  away at the wood.)";
40
                    other.elevator_solution = "Pickaxe";
41
                    break;
42
                case "Steel Buckle":
43
                case "Flint":
44
                    if (scr_item_exists_check
scr_item_exists_check

function scr_item_exists_check(arg0) { for (var i = 1; i <= 8; i += 1) { if (global.item_slot[i] == arg0) { return true; exit; break; } else if (i == 8) { return false; } } }
("Flint") && scr_item_exists_check
scr_item_exists_check

function scr_item_exists_check(arg0) { for (var i = 1; i <= 8; i += 1) { if (global.item_slot[i] == arg0) { return true; exit; break; } else if (i == 8) { return false; } } }
("Steel Buckle"))
45
                    {
46
                        message[0] = "* (You start rubbing the steel#  buckle against the flint.)";
47
                        other.elevator_solution = "Flint & Steel";
48
                    }
49
                    else
50
                    {
51
                        message[0] = "* (You can't think of a way to#  make this work.)";
52
                        global.cutscene = false;
53
                    }
54
                    break;
55
                case "Matches":
56
                    message[0] = "* (You strike a match on the#  piece of wood.)";
57
                    other.elevator_solution = "Matches";
58
                    break;
59
            }
60
        }
61
        if (!global.dialogue_open)
62
            global.item_used_overworld = undefined;
63
    }
64
    if (!global.dialogue_open && elevator_solution != "none")
65
    {
66
        var newsprite, newsound, newmessage;
67
        switch (elevator_solution)
68
        {
69
            case "Pickaxe":
70
                newsprite = 1014;
71
                newmessage = "* (The pickaxe broke.)";
72
                newsound = 251;
73
                break;
74
            case "Flint & Steel":
75
                newsprite = 1013;
76
                newmessage = "* (The flint crumbled away and#  the buckle melted.)";
77
                newsound = 249;
78
                scr_item_remove
scr_item_remove

function scr_item_remove(arg0) { for (i = 1; i <= 8; i += 1) { if (global.item_slot[i] == arg0) { while (i < 8) { global.item_slot[i] = global.item_slot[i + 1]; i += 1; } global.item_slot[8] = "Nothing"; return true; break; } else if (i == 8) { return false; } } }
("Flint");
79
                scr_item_remove
scr_item_remove

function scr_item_remove(arg0) { for (i = 1; i <= 8; i += 1) { if (global.item_slot[i] == arg0) { while (i < 8) { global.item_slot[i] = global.item_slot[i + 1]; i += 1; } global.item_slot[8] = "Nothing"; return true; break; } else if (i == 8) { return false; } } }
("Steel Buckle");
80
                break;
81
            case "Matches":
82
                newsprite = 1013;
83
                newmessage = "* (The whole box of matches#  caught fire and burnt up.)";
84
                newsound = 249;
85
                break;
86
        }
87
        if (sprite_index == spr_dunes_13_elevator)
88
        {
89
            scr_item_remove
scr_item_remove

function scr_item_remove(arg0) { for (i = 1; i <= 8; i += 1) { if (global.item_slot[i] == arg0) { while (i < 8) { global.item_slot[i] = global.item_slot[i + 1]; i += 1; } global.item_slot[8] = "Nothing"; return true; break; } else if (i == 8) { return false; } } }
(elevator_solution);
90
            sprite_index = newsprite;
91
            audio_play_sound(newsound, 1, 0);
92
            image_speed = 0.3;
93
            timer = 30;
94
        }
95
        else if (image_index >= (image_number - 1))
96
        {
97
            if (!scr_timer
scr_timer

function scr_timer() { if (timer > 0) { timer--; return false; } else { return true; } }
())
98
            {
99
                image_speed = 0;
100
                exit;
101
            }
102
            else if (sprite_index == newsprite)
103
            {
104
                audio_play_sound(snd_elevator_open, 1, 0);
105
                sprite_index = spr_dunes_13_elevator_fixed;
106
                image_speed = 0.3;
107
                image_index = 0;
108
                exit;
109
            }
110
            image_speed = 0;
111
            instance_create(obj_pl.x, obj_pl.y, obj_npc_clover_dunes_12);
112
            global.dunes_flag[4] = 2;
113
            scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
114
            with (msg)
115
                message[0] = newmessage;
116
        }
117
    }
118
}
119
else
120
{
121
    if (keyboard_multicheck_pressed(0) && scr_interact
scr_interact

function scr_interact() { if (distance_to_object(obj_pl) < 20 && obj_pl.state == scr_normal_state) { var pl_dir = obj_pl.direction; var pl_x = 0; var pl_y = 0; var check_distance_x = 0; var check_distance_y = 0; switch (pl_dir) { case 0: pl_x = obj_pl.bbox_right; pl_y = obj_pl.bbox_top + 1; check_distance_x = 20; break; case 180: pl_x = obj_pl.bbox_left; pl_y = obj_pl.bbox_top + 1; check_distance_x = -20; break; case 90: pl_x = obj_pl.x; pl_y = obj_pl.bbox_top; check_distance_y = -20; break; case 270: pl_x = obj_pl.x; pl_y = obj_pl.bbox_bottom; check_distance_y = 20; break; } if (collision_line_first(pl_x, pl_y, pl_x + check_distance_x, pl_y + check_distance_y, id, false, false)) return true; } }
() && image_speed == 0)
122
    {
123
        if (image_speed == 0)
124
        {
125
            scr_cutscene_start
scr_cutscene_start

function scr_cutscene_start() { global.cutscene = true; obj_pl.state = scr_frozen_state; obj_pl.image_index = 0; obj_pl.image_speed = 0; }
();
126
            image_speed = 0.3;
127
            audio_play_sound(snd_elevator_open, 1, 0);
128
            exit;
129
        }
130
    }
131
    if (floor(image_index) <= 0 && image_speed < 0)
132
    {
133
        image_speed = 0;
134
        image_index = 0;
135
    }
136
    if (image_index >= (image_number - 1) && image_speed > 0)
137
    {
138
        image_speed = 0;
139
        instance_create(obj_pl.x, obj_pl.y, obj_npc_clover_dunes_12);
140
    }
141
}