How to save changes in a room

GenoCrayon

Member
Hello, I've made a game where you can collect coins and other collectibles by destroying pots for example.
The problem I'm having is that whenever I change rooms and then go back to the room where I destroyed the pots, the pots are back again.
Does anyone know how to fix this?
 

TheouAegis

Member
First you'll need to make sure you have a room that will be run at the very start of the game before anything else ever happens. In that room you need to initialize of your Global variables. Among those global variables, you need to make an array for each room. Inside those arrays, you will keep the status of each pot the game needs to remember. Now give your pot instances a Creation Code (in the room editor) and assign a unique number to them startinf from 0 and counting up by 1 for each room (e.g., 0 thru 6 in one room, 0 the 12 in another room). In the Room Start event of the pot object, have the pot look up the array for the room it is in and then find the index corresponding to its unique identifier. If that value in the array is 1, destroy the pot. Lastly, when the player destroys a pot (DO NOT USE THE DESTROY EVENT), look up the array for the room and find the destroyed pot's identifier in the array, and set it to 1.
 

GenoCrayon

Member
First you'll need to make sure you have a room that will be run at the very start of the game before anything else ever happens. In that room you need to initialize of your Global variables. Among those global variables, you need to make an array for each room. Inside those arrays, you will keep the status of each pot the game needs to remember. Now give your pot instances a Creation Code (in the room editor) and assign a unique number to them startinf from 0 and counting up by 1 for each room (e.g., 0 thru 6 in one room, 0 the 12 in another room). In the Room Start event of the pot object, have the pot look up the array for the room it is in and then find the index corresponding to its unique identifier. If that value in the array is 1, destroy the pot. Lastly, when the player destroys a pot (DO NOT USE THE DESTROY EVENT), look up the array for the room and find the destroyed pot's identifier in the array, and set it to 1.
Thanks a lot, I'll try that!
 
Top