Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMS 2.3.3+ supports default values now #1

Open
gnysek opened this issue Aug 26, 2021 · 1 comment
Open

GMS 2.3.3+ supports default values now #1

gnysek opened this issue Aug 26, 2021 · 1 comment

Comments

@gnysek
Copy link

gnysek commented Aug 26, 2021

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);
}
@gnysek gnysek changed the title GMS 2.3.3+ supports default values GMS 2.3.3+ supports default values now Aug 26, 2021
@twisterghost
Copy link
Contributor

twisterghost commented Oct 9, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants