RedditPP Mascot

RedditPP

r/gamemaker • … • u/C_Degheg

Is there a way to directly mention an instance id in GML (and more generally a ref) ?

And if so : how ?

I'm currently working on levers that should have multiple uses in my game, notably affect certain instances.

The way i want to do it is by having a general code in the object, basically : when activated call lever\_function with lever\_args and definine lever\_function and lever\_args in the instance creation code. Now i want one of my levers to toggle the movement of specific moving platforms, so i made :

`/// @desc` `Starts or stops the movement of designated moving platforms`

`/// @arg` `{Array}` `platform_ids` `An array of the ids of the affected platforms`

`function toggle_platform_movement(platform_ids) {`

`for (var i=0; i>=len(platform_ids); i++) {`

`if object_get_name(platform_ids[i]) == "obj_moving_platform" {`

`pf = platform_ids[i]`

`pf.active = not pf.active`

`}`

`else {`

`show_error("Warning! - " + string(platform_ids[i]) + " at index " + string(i) + " of platform_ids is not a platform", false)`

`}`

`}`

`}`

But even though i am able to know what is the id of said platforms (with a show\_debug\_message) i can't mention them in the lever creation code.

I think i can put in place a solution in this specific case, by having every platform sending their id to a ds\_table indicating their line within they're creation code. But it's far from a practical solution when i will have 35 tables with hundreds of lines.

And this is not the first time it is a problem not being able to mention a ref. So if there's no way to do it pls devs add it.

— 0