Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_snd_maker_Step_0

(view raw script w/o annotations or w/e)
1
if (!
scr_debug
scr_debug

function
scr_debug()
{ if (global.debug == 1) return 1; }
())
2
    instance_destroy();
3
if (up_h())
4
    ubuff++;
5
else
6
    ubuff = 0;
7
if (down_h())
8
    dbuff++;
9
else
10
    dbuff = 0;
11
if (left_h())
12
    lbuff++;
13
else
14
    lbuff = 0;
15
if (right_h())
16
    rbuff++;
17
else
18
    rbuff = 0;
19
but1_h = keyboard_check(ord("Z")) || gamepad_button_check(0, gp_face1) || gamepad_button_check(1, gp_face1);
20
but1_p = keyboard_check_pressed(ord("Z")) || gamepad_button_check_pressed(0, gp_face1) || gamepad_button_check_pressed(1, gp_face1);
21
but2_h = keyboard_check(ord("X")) || gamepad_button_check(0, gp_face2) || gamepad_button_check(1, gp_face2);
22
but2_p = keyboard_check_pressed(ord("X")) || gamepad_button_check_pressed(0, gp_face2) || gamepad_button_check_pressed(1, gp_face2);
23
but3_h = keyboard_check(ord("C")) || gamepad_button_check(0, gp_face4) || gamepad_button_check(1, gp_face4);
24
but3_p = keyboard_check_pressed(ord("C")) || gamepad_button_check_pressed(0, gp_face4) || gamepad_button_check_pressed(1, gp_face4);
25
but4_h = keyboard_check(ord("V")) || gamepad_button_check(0, gp_face3) || gamepad_button_check(1, gp_face3);
26
but4_p = keyboard_check_pressed(ord("V")) || gamepad_button_check_pressed(0, gp_face3) || gamepad_button_check_pressed(1, gp_face3);
27
but5_h = keyboard_check(ord("E")) || gamepad_button_check(0, gp_shoulderr) || gamepad_button_check(1, gp_shoulderr);
28
but5_p = keyboard_check_pressed(ord("E")) || gamepad_button_check_pressed(0, gp_shoulderr) || gamepad_button_check_pressed(1, gp_shoulderr);
29
but6_h = keyboard_check(ord("Q")) || gamepad_button_check(0, gp_shoulderl) || gamepad_button_check(1, gp_shoulderl);
30
but6_p = keyboard_check_pressed(ord("Q")) || gamepad_button_check_pressed(0, gp_shoulderl) || gamepad_button_check_pressed(1, gp_shoulderl);
31
quit = keyboard_check_pressed(vk_escape) || gamepad_button_check_pressed(0, gp_select) || gamepad_button_check_pressed(1, gp_select);
32
var updatecurrent = false;
33
var addnew = false;
34
var renderaudio = false;
35
var copytext = false;
36
if (keyboard_check(vk_control) && keyboard_check_pressed(ord("C")))
37
    copytext = true;
38
if (but3_p)
39
{
40
    addnew = true;
41
    but3_p = 0;
42
}
43
if (but4_p)
44
{
45
    updatecurrent = true;
46
    but4_p = 0;
47
}
48
if (keyboard_check_pressed(vk_space) || gamepad_button_check_pressed(0, gp_shoulderrb) || gamepad_button_check_pressed(1, gp_shoulderrb))
49
    renderaudio = true;
50
if (page == 0)
51
{
52
    var repeatrate = 7;
53
    if (ubuff == 1)
54
        ubuff = repeatrate;
55
    if (lbuff == 1)
56
        lbuff = repeatrate;
57
    if (dbuff == 1)
58
        dbuff = repeatrate;
59
    if (rbuff == 1)
60
        rbuff = repeatrate;
61
    if (ubuff && (ubuff % repeatrate) == 0)
62
    {
63
        mpos--;
64
        ubuff++;
65
    }
66
    if (lbuff && (lbuff % repeatrate) == 0)
67
    {
68
        mpos -= 10;
69
        lbuff++;
70
    }
71
    if (dbuff && (dbuff % repeatrate) == 0)
72
    {
73
        mpos++;
74
        dbuff++;
75
    }
76
    if (rbuff && (rbuff % repeatrate) == 0)
77
    {
78
        mpos += 10;
79
        rbuff++;
80
    }
81
    if (mpos < 0)
82
        mpos += soundtotal;
83
    if (mpos > (soundtotal - 1))
84
        mpos -= soundtotal;
85
    cursound = soundName[mpos];
86
    pageind[0] = mpos;
87
}
88
else if (page == 1)
89
{
90
    var repeatrate = 7;
91
    if (ubuff == 1)
92
        ubuff = repeatrate;
93
    if (lbuff == 1)
94
        lbuff = repeatrate;
95
    if (dbuff == 1)
96
        dbuff = repeatrate;
97
    if (rbuff == 1)
98
        rbuff = repeatrate;
99
    var down = 0;
100
    var up = 0;
101
    var left = 0;
102
    var right = 0;
103
    if (ubuff && (ubuff % repeatrate) == 0)
104
    {
105
        up = 1;
106
        ubuff++;
107
    }
108
    if (lbuff && (lbuff % repeatrate) == 0)
109
    {
110
        left = 1;
111
        lbuff++;
112
    }
113
    if (dbuff && (dbuff % repeatrate) == 0)
114
    {
115
        down = 1;
116
        dbuff++;
117
    }
118
    if (rbuff && (rbuff % repeatrate) == 0)
119
    {
120
        right = 1;
121
        rbuff++;
122
    }
123
    if (down)
124
        mpos++;
125
    if (up)
126
        mpos--;
127
    if (mpos == 0)
128
    {
129
        if (left)
130
            curvolume -= 0.05;
131
        if (right)
132
            curvolume += 0.05;
133
        curvolume = clamp(curvolume, 0, 2);
134
    }
135
    if (mpos == 1)
136
    {
137
        if (left)
138
            curpitch -= 0.05;
139
        if (right)
140
            curpitch += 0.05;
141
        curpitch = clamp(curpitch, 0, 20);
142
    }
143
    if (mpos == 2)
144
    {
145
        if (left)
146
            curdelay -= 1;
147
        if (right)
148
            curdelay += 1;
149
        if (but1_p)
150
        {
151
            but1_p = 0;
152
            curdelay = get_integer("Enter Delay", curdelay);
153
        }
154
        if (curdelay < 0)
155
            curdelay = 0;
156
    }
157
    if (mpos == 3)
158
    {
159
        if (left)
160
            curlooprate -= 1;
161
        if (right)
162
        {
163
            curlooprate += 1;
164
            if (curlooprate == 0)
165
                curlooprate = 1;
166
        }
167
        if (but1_p)
168
        {
169
            but1_p = 0;
170
            curlooprate = get_integer("Enter Loop Rate", curlooprate);
171
        }
172
        if (curlooprate < 1)
173
            curlooprate = -1;
174
    }
175
    if (mpos == 4)
176
    {
177
        if (left || right || but1_p)
178
        {
179
            curkillsnd = !curkillsnd;
180
            but1_p = 0;
181
        }
182
    }
183
    if (mpos == 5)
184
    {
185
        if (but1_p)
186
        {
187
            but1_p = 0;
188
            addnew = true;
189
        }
190
    }
191
    if (mpos == 6)
192
    {
193
        if (but1_p)
194
        {
195
            but1_p = 0;
196
            updatecurrent = true;
197
        }
198
    }
199
    if (mpos == 7)
200
    {
201
        if (but1_p)
202
        {
203
            but1_p = 0;
204
            if (sndcount > 0)
205
            {
206
                array_delete(snd, cursnd, 1);
207
                array_delete(pitch, cursnd, 1);
208
                array_delete(delay, cursnd, 1);
209
                array_delete(volume, cursnd, 1);
210
                array_delete(looprate, cursnd, 1);
211
                array_delete(killsnd, cursnd, 1);
212
                sndcount--;
213
                array_push(snd, -1);
214
                array_push(pitch, 1);
215
                array_push(delay, 0);
216
                array_push(volume, 1);
217
                array_push(looprate, -1);
218
                array_push(killsnd, false);
219
                cursnd--;
220
                if (cursnd < 0)
221
                    cursnd = 0;
222
            }
223
        }
224
    }
225
    if (mpos == 8)
226
    {
227
        if (but1_p)
228
        {
229
            but1_p = 0;
230
            renderaudio = true;
231
        }
232
    }
233
    if (mpos == 9)
234
    {
235
        if (left)
236
            curlifetime -= 1;
237
        if (right)
238
        {
239
            curlifetime += 1;
240
            if (curlifetime == 0)
241
                curlifetime = 1;
242
        }
243
        if (but1_p)
244
        {
245
            but1_p = 0;
246
            curlifetime = get_integer("Enter Lifetime", curlifetime);
247
        }
248
        if (curlifetime < 1)
249
            curlifetime = -1;
250
    }
251
    if (mpos == 10)
252
    {
253
        if (left || right || but1_p)
254
        {
255
            curkillall = !curkillall;
256
            but1_p = 0;
257
        }
258
    }
259
    if (mpos == 11)
260
    {
261
        if (left || right || but1_p)
262
        {
263
            curkillind = !curkillind;
264
            but1_p = 0;
265
        }
266
    }
267
    if (mpos > 11)
268
        mpos = 0;
269
    if (mpos < 0)
270
        mpos = 11;
271
    pageind[1] = mpos;
272
}
273
if (page == 2)
274
{
275
    if (dbuff == 1)
276
        cursnd++;
277
    if (ubuff == 1)
278
        cursnd--;
279
    if (cursnd < 0)
280
        cursnd = sndcount - 1;
281
    if (cursnd > (sndcount - 1))
282
        cursnd = 0;
283
    if (but5_p || (keyboard_check_pressed(vk_tab) && !keyboard_check(vk_alt)) || but6_p)
284
    {
285
        if (sndcount > 0)
286
        {
287
            cursound = snd[cursnd];
288
            curvolume = volume[cursnd];
289
            curpitch = pitch[cursnd];
290
            curdelay = delay[cursnd];
291
            curlooprate = looprate[cursnd];
292
            curkillsnd = killsnd[cursnd];
293
            var soundtofind = audio_get_name(snd[cursnd]);
294
            for (var i = 0; i < array_length(soundName); i++)
295
            {
296
                if (soundName[i] == soundtofind)
297
                    pageind[0] = i;
298
            }
299
        }
300
    }
301
}
302
var maxpage = 2;
303
if (but5_p || (keyboard_check_pressed(vk_tab) && !keyboard_check(vk_alt)))
304
{
305
    but5_p = 0;
306
    pageind[page] = mpos;
307
    page++;
308
    if (page > maxpage)
309
        page = 0;
310
    mpos = pageind[page];
311
}
312
if (but6_p)
313
{
314
    but6_p = 0;
315
    pageind[page] = mpos;
316
    page--;
317
    if (page < 0)
318
        page = maxpage;
319
    mpos = pageind[page];
320
}
321
if (but1_p)
322
{
323
    snd_stop(playsnd);
324
    playsnd = snd_play(asset_get_index(cursound), curvolume, curpitch);
325
}
326
if (but2_p)
327
{
328
    snd_stop(playsnd);
329
    with (complexsound)
330
    {
331
        killall = true;
332
        instance_destroy();
333
    }
334
}
335
if (copytext)
336
{
337
    but3_p = 0;
338
    addnew = false;
339
    var commandstring = "var snd=snd_play_complex(" + string(curkillall) + "," + string(curkillind) + "," + string(curlifetime) + ");\t";
340
    for (var i = 0; i < sndcount; i++)
341
        commandstring += ("snd_add_complex(snd," + string(i) + "," + string(audio_get_name(snd[i])) + "," + string(pitch[i]) + "," + string(volume[i]) + "," + string(delay[i]) + "," + string(looprate[i]) + "," + string(killsnd[i]) + ");\t");
342
    debug_print("Copied command to clipboard");
343
    clipboard_set_text(commandstring);
344
}
345
if (quit)
346
    instance_destroy();
347
if (addnew)
348
{
349
    cursound = soundName[pageind[0]];
350
    snd[sndcount] = asset_get_index(cursound);
351
    volume[sndcount] = curvolume;
352
    pitch[sndcount] = curpitch;
353
    delay[sndcount] = curdelay;
354
    looprate[sndcount] = curlooprate;
355
    killsnd[sndcount] = curkillsnd;
356
    sndcount++;
357
    cursnd = sndcount - 1;
358
}
359
if (updatecurrent)
360
{
361
    cursound = soundName[pageind[0]];
362
    snd[cursnd] = asset_get_index(cursound);
363
    volume[cursnd] = curvolume;
364
    pitch[cursnd] = curpitch;
365
    delay[cursnd] = curdelay;
366
    looprate[cursnd] = curlooprate;
367
    killsnd[cursnd] = curkillsnd;
368
    if (i_ex(complexsound))
369
        renderaudio = true;
370
}
371
if (renderaudio)
372
{
373
    snd_stop(playsnd);
374
    with (obj_snd_complex)
375
    {
376
        killall = true;
377
        instance_destroy();
378
    }
379
    complexsound = snd_play_complex(curlifetime, curkillall, curkillind);
380
    for (var i = 0; i < sndcount; i++)
381
    {
382
        if (snd[i] != -1)
383
            snd_add_complex(complexsound, i, snd[i], pitch[i], volume[i], delay[i], looprate[i], killsnd[i]);
384
    }
385
}