object_set_persistent

Sets the persistence of the given object.

Syntax:

object_set_persistent(index, pers);


Argument Description
index The index of the object to change.
pers Whether the object should be flagged as persistent (true) or not (false).


Returns: N/A


Description

With this function you can set the persistence of a specific object. A persistent object is "carried over" from room to room and maintains its properties at all times (for more information on persistence see Defining Objects). Setting the persistence of the object means that all instances of this object that are created after the persistence has been changed will be created persistent, while instances that are already in the room may not be affected.

Please note that this is not an instance function! You can set the persistent flag of individual instances using the persistent variable and so have ten instances all flagged as persistent even though the object in question has the flag set to false in the IDE, and even if you change the persistent flag of the object to true using this function, all instances that currently in the room will remain as they were, and only instances created after calling the function will start with persistent flagged as true.


Example:

if room == rm_final object_set_persistent(obj_Player, 0); instance_create_layer(32, 32, "Instances", obj_Player);

The above code checks to see in which room the instance is currently in and if it is in the specified "rm_final" then it sets the persistence of the object "obj_Player" to false and then creates the instance.


Back: Objects
Next: object_set_solid
© Copyright YoYo Games Ltd. 2018 All Rights Reserved