• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HELP WITH ROOM PERSISTANCE

J

Jhamil92

Guest
Does anybody know how to make certain collected items delete from a room for good but reset everything else?
thank you,
Joel
 

Fredrik

Member
It's abit hard without more context, but try:

Create event of the object being collected:
GML:
myid   = string(object_get_name(object_index)) + string(x) + string(y);
picked = 0;

var file = 'picked.ini';
if file_exists(file)
    {
    ini_open(file)
    picked = ini_read_real('items',myid,0);
    ini_close();
    }

if picked = 1
    {instance_destroy();}
In the code where you pick up the item:
GML:
var file 'picked.ini';
if file_exists(file)
    {
    ini_open(file)
    ini_write_real('picked',myid,picked);
    ini_close();
    }
I didnt try the code myself tho' so hope it works! if it doesnt work, try moving everything in the create event that is written below the picked = 0; to an alarm.
 
Last edited:

rytan451

Member
If the room is persistent (with the persistent checkbox checked in the room editor), then destroying the instance by any method (typically instance_destroy()) will lead to the instance remaining destroyed when the room is entered once more.
 
Top