Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_robot_build_controller_Step_0

(view raw script w/o annotations or w/e)
1
if live_call()
2
    return global.live_result;
3
if (destroy_self == true)
4
{
5
    draw_alpha = lerp(draw_alpha, 0, 0.2)
6
    if (draw_alpha == 0)
7
    {
8
        global.sworks_robot_count = instance_number(obj_robot_build_item)
9
        var x_origin = 60
10
        var y_origin = 140
11
        var i = 0
12
        with (obj_robot_build_item)
13
        {
14
            global.sworks_robot_sprite[i] = sprite_index
15
            global.sworks_robot_x[i] = x_origin - x
16
            global.sworks_robot_y[i] = y_origin - y
17
            global.sworks_robot_depth[i] = depth
18
            global.sworks_robot_angle[i] = image_angle
19
            global.sworks_robot_scale[i] = image_xscale
20
            i += 1
21
        }
22
        instance_destroy()
23
        instance_destroy(obj_robot_build_cursor)
24
        instance_destroy(obj_robot_build_item)
25
    }
26
    return;
27
}
28
if global.dialogue_open
29
    return;
30
draw_alpha = lerp(draw_alpha, 1, 0.2)
31
var confirm_key = keyboard_multicheck_pressed(0)
32
var cancel_key = keyboard_multicheck_pressed(1)
33
var cursor_x = obj_robot_build_cursor.x
34
var cursor_y = obj_robot_build_cursor.y
35
if point_in_rectangle(cursor_x, cursor_y, 360, 20, 470, 150)
36
    robot_item_selected = 0
37
else if point_in_rectangle(cursor_x, cursor_y, 470, 20, 580, 150)
38
    robot_item_selected = 1
39
else if point_in_rectangle(cursor_x, cursor_y, 360, 150, 470, 280)
40
    robot_item_selected = 2
41
else if point_in_rectangle(cursor_x, cursor_y, 470, 150, 580, 280)
42
    robot_item_selected = 3
43
else
44
    robot_item_selected = -1
45
if point_in_rectangle(cursor_x, cursor_y, 500, 320, 580, 370)
46
    gui_button_selected = 0
47
else if point_in_rectangle(cursor_x, cursor_y, 500, 398, 580, 448)
48
    gui_button_selected = 1
49
else
50
    gui_button_selected = -1
51
if confirm_key
52
{
53
    if (robot_item_selected != -1)
54
    {
55
        var robot_item_number = instance_number(obj_robot_build_item)
56
        if (robot_item_number >= item_number_max)
57
            audio_play_sound(snd_fail, 1, 0)
58
        else
59
        {
60
            robot_move_to_position = true
61
            obj_robot_build_cursor.soul_can_move = false
62
            obj_robot_build_cursor.image_alpha_base = 0.5
63
            robot_item_placed[item_number] = instance_create(obj_robot_build_cursor.x, obj_robot_build_cursor.y, obj_robot_build_item)
64
            with (robot_item_placed[item_number])
65
                sprite_index = other.robot_item[other.robot_item_selected]
66
            item_number += 1
67
            audio_play_sound(snd_mainmenu_select, 1, 0)
68
        }
69
    }
70
    if (gui_button_selected != -1)
71
    {
72
        if (gui_button_selected == 0 && item_number > 0)
73
        {
74
            instance_destroy(robot_item_placed[(item_number - 1)])
75
            item_number -= 1
76
            audio_play_sound(snd_confirm, 1, 0)
77
        }
78
        else if (gui_button_selected == 1)
79
        {
80
            audio_play_sound(snd_confirm, 1, 0)
81
            if (!instance_exists(obj_robot_build_dialogue_confirm))
82
                instance_create(0, 0, obj_robot_build_dialogue_confirm)
83
        }
84
    }
85
}
86
if (robot_item_selected != -1)
87
    robot_item_scale[robot_item_selected] = lerp(robot_item_scale[robot_item_selected], 1.3, 0.15)
88
for (i = 0; i < array_length_1d(robot_item_scale); i++)
89
{
90
    if (i != robot_item_selected)
91
        robot_item_scale[i] = lerp(robot_item_scale[i], 1, 0.25)
92
}
93
if (robot_move_to_position == true)
94
{
95
    obj_robot_build_cursor.x = lerp(obj_robot_build_cursor.x, 170, 0.3)
96
    obj_robot_build_cursor.y = lerp(obj_robot_build_cursor.y, 150, 0.3)
97
    if (round(obj_robot_build_cursor.x) == 170 && round(obj_robot_build_cursor.y) == 150)
98
    {
99
        robot_move_to_position = false
100
        obj_robot_build_cursor.soul_can_move = true
101
        obj_robot_build_cursor.image_alpha_base = 1
102
    }
103
}