^This! For sure.
Anyway, I will give you a little more insight into the hodge-podge idea I wrote up.
I did make up the Room
Restart Event .
Sorry.
You tried putting code into the
Room Start Event, but instead I would try to make the same thing happen wherever you currently call:
room_restart()
A
with() construction could come in handy, I'd read that page in the manual. You could also probably do something like:
obj_persistent.
alarm[0] = 1;
The idea goes as follows:
---------------------------------------------------------------------------------------
In the beginning, we create a persistent controller that stores a list. At first the list is empty.
We assume that when you pick up an item, it's instance in the room gets destroyed.
So at some point when that happens ( it could be where it calls instance_destroy(), in it's Destroy Event, or it's parents Destroy Event ) we need to add the items
id to the controllers list.
Later when you restart the room, we need to make sure the controllers Alarm Zero is to 1 so it waits a step. Once the room is loaded we can loop through the list and destroy instances with those
id's.
The controller is persistent so it remembers the destroy list even if the room is restarted.
--------------------------------------------------------------------------------------------------------------------------
I usually go through a process of trial and error, so I wasn't trying to claim this idea would work straight out.
There are more things to consider with this solution, and that's why I agree with studying and going through a polished tutorial.
PixelatedPope is dope, I'm subscribed.
Issues with my idea I've thought about:
We need to make sure not to create the persistent controller at Room Start!
Or to drop it into a room in the Room Editor! (unless it's a menu / start room that's only visited once)
There are two reasons for this:
1) If you visit the room more than once, it will create duplicate controllers.
2) If the room restarts, it might throw off the numbers that instances in the room are given as id's. Then the list could store the wrong (or non existing) instances to destroy.
This idea also doesn't remember items you picked up in other rooms. Make sure to ds_list_clear() the list when you switch rooms.