gm-core / particore

Simplified particle type generation for GameMaker: Studio 2
https://gmcore.io/particore/
7 stars 1 forks source link

GMS 2.3.3+ supports default values now #1

Open gnysek opened 3 years ago

gnysek commented 3 years ago

Most of functions can be simplified, as argument_count isn't required anymore - default values can be set instead.

For example:

function pt_size() {

    var minSize = argument[0];
    var maxSize = minSize;
    var inc = 0;
    var wiggle = 0;

    if (argument_count > 1) {
        maxSize = argument[1];
    }

    if (argument_count > 2) {
        inc = argument[2];
    }

    if (argument_count > 3) {
        wiggle = argument[3];
    }

    part_type_size(global.__part_gen_type, argument[0], argument[1], inc, wiggle);
}

Becomes

function pt_size(minSize = 0, maxSize = undefined, inc = 0, wiggle = 0) {

    if (is_undefined(maxSize) {
        maxSize = minSize;
    }

    part_type_size(global.__part_gen_type, minSize, maxSize, inc, wiggle);
}
twisterghost commented 2 years ago

Yes, definitely. I've got a few things I'd like to overhaul in Particore and this is absolutely a part of that. Sorry for the late reply.