persistent
Returns: Boolean
This variable can be read to find out if the instance is flagged
as persistent or not, or it can used to set persistence to
true (persistent) or false (not persistent) for
the instance. A persistent instance is one that will be "carried
over" from room to room, meaning (for example) that it only has to
be created once at the start of the game and it will be present in
all further rooms. Care should be taken with persistence as it is
easy to lose track of persistent instances which can lead to
problems later in the development of the game.
A persistent object will still have its Game Start, Game
End, Room Start and Room End events triggered,
however if you restart the game (with, for example, the
game_restart() function) all persistent objects will be
removed and only exist when created again by the game. Also note
that if you deactivate a persistent object, it will no longer pass
from one room to another unless re-activated before the Room End
event is triggered.
if !persistent
{
persistent = true;
}
The above code will check the instance to see if persistence is flagged as false and if the instance is NOT persistent the persistence flag is set to true.