Skip to content
This repository was archived by the owner on Jul 30, 2023. It is now read-only.

'GetObjectInstances' function (EN)

Archie edited this page May 23, 2021 · 1 revision

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

Clone this wiki locally