'GetObjectInstances' function (EN) - Archie-osu/ProjectDELTA GitHub Wiki

GetObjectInstances function

Returns all currently loaded instances of a particular object

Syntax

<RValue> GetObjectInstances(
    <real> MasterID
);

Parameters

MasterID

Type: Real

The master ID of the object. Refer to the GetAssetID function to get possible values.

Return Value

Type: RValue

An array of RValues, containing instance IDs of all instantiated objects.

You can use this ID with GameMaker functions like instance_destroy.

Example

local id = GetAssetID("obj_savepoint"); -- Get the master ID of obj_savepoint
local instances = GetObjectInstances(id.realval); -- Get all the instances of it

for index=1, #instances do
	local v = instances[index]; -- Loop over all the instances 
	print("Loaded Instance ID: " .. v.realval) -- Print their IDs to the console
end
⚠️ **GitHub.com Fallback** ⚠️