GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2018-01-18 07:31:27

gnysek
Member
Registered: 2011-12-29
Posts: 36

instance_number_exact

Since instance_number also counts childrens, here it's version which checks exactly for object type:


Expand	/// @desc returns number of instances of given object type, without it's childs
	/// @param object_id int

	var __total = 0;
	with (argument0) {
		if (object_index == argument0) __total++;
	}
	
	return __total;

Offline

#2 2018-01-19 03:08:26

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: instance_number_exact

Oh, this is a good idea for a script. I've never really considered if instance_number() includes descendants. That behavior is not documented.


Abusing forum power since 1986.

Offline

#3 2018-01-30 08:24:15

gnysek
Member
Registered: 2011-12-29
Posts: 36

Re: instance_number_exact

It will be documented in next release of GMS2, as I reported this as bug, seeing it includes descendants. The reply was to create a script like above instead of fixing function smile

Offline

Board footer

Powered by FluxBB