Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_scr_verlet_updatesticks

(view raw script w/o annotations or w/e)
1
function scr_verlet_updatesticks
scr_verlet_updatesticks

function scr_verlet_updatesticks(argument0) //gml_Script_scr_verlet_updatesticks { for (var i = 0; i < array_length(argument0); i++) { var s = array_get(argument0, i) var dx = (array_get(array_get(s, 1), 0)) - (array_get(array_get(s, 0), 0)) var dy = (array_get(array_get(s, 1), 1)) - (array_get(array_get(s, 0), 1)) var distance = sqrt(dx * dx + dy * dy) var difference = (array_get(s, 2)) - distance var percent = difference / distance / 2 var offsetX = dx * percent var offsetY = dy * percent if (!(array_get(array_get(s, 0), 4))) { array_set(array_get(s, 0), 0, ((array_get(array_get(s, 0), 0)) - offsetX)) array_set(array_get(s, 0), 1, ((array_get(array_get(s, 0), 1)) - offsetY)) } if (!(array_get(array_get(s, 1), 4))) { array_set(array_get(s, 1), 0, ((array_get(array_get(s, 1), 0)) + offsetX)) array_set(array_get(s, 1), 1, ((array_get(array_get(s, 1), 1)) + offsetY)) } } }
(argument0) //gml_Script_scr_verlet_updatesticks
2
{
3
    for (var i = 0; i < array_length(argument0); i++)
4
    {
5
        var s = array_get(argument0, i)
6
        var dx = (array_get(array_get(s, 1), 0)) - (array_get(array_get(s, 0), 0))
7
        var dy = (array_get(array_get(s, 1), 1)) - (array_get(array_get(s, 0), 1))
8
        var distance = sqrt(dx * dx + dy * dy)
9
        var difference = (array_get(s, 2)) - distance
10
        var percent = difference / distance / 2
11
        var offsetX = dx * percent
12
        var offsetY = dy * percent
13
        if (!(array_get(array_get(s, 0), 4)))
14
        {
15
            array_set(array_get(s, 0), 0, ((array_get(array_get(s, 0), 0)) - offsetX))
16
            array_set(array_get(s, 0), 1, ((array_get(array_get(s, 0), 1)) - offsetY))
17
        }
18
        if (!(array_get(array_get(s, 1), 4)))
19
        {
20
            array_set(array_get(s, 1), 0, ((array_get(array_get(s, 1), 0)) + offsetX))
21
            array_set(array_get(s, 1), 1, ((array_get(array_get(s, 1), 1)) + offsetY))
22
        }
23
    }
24
}