• 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!

Legacy GM How to set object persistence in only 2 Rooms?

A

Alex H

Guest
So basically I'm making a Game where the main object will be only be used in only 2 of 10 rooms. How would I go about making this object persistent in only 2 rooms?

(To give a bit more insight, its a pet game, in which I have about 10 rooms, each with its own function. The pet stays in the living room most of the time but I would need to have him transfer over to the bathroom so The player can give the pet a bath) I do not want to just create another pet object in 2 different rooms because the pet has its own stats, and has different sprites used as the pet gets older.)

This thread is two threads merged into one. Please don't make duplicate topics. As you can see this post is the first post from both topics merged into one post. Regards, @Weird Dragon

So basically I'm making a Game where the main object will be only be used in only 2 of 10 rooms. How would I go about making this object persistent in only 2 rooms?

(To give a bit more insight, its a pet game, in which I have about 10 rooms, each with its own function. The pet stays in the living room most of the time but I would need to have him transfer over to the bathroom so The player can give the pet a bath) I do not want to just create another pet object in 2 different rooms because the pet has its own stats, and has different sprites used as the pet gets older.)
 
Last edited by a moderator:

chamaeleon

Member
Maintain pet state in some controller object that persistent (across all rooms), and create a pet instance in the room you need it when the room is active, and make use of the information in the pet state controller object? In other words, the pet instance is then just to handle the visuals and interaction and as such creating and destroying the instance wouldn't influence the state information. Regardless of which room you are in, presumably the pet would still "exist" (in some deep metaphysical sense), so if you go to a room where there is no pet, and then go back, you'd want the pet to be there, I would imagine. The state information would include what sprites to use, which room the pet is currently in, etc. and you'd read that information and create or update the pet instance as needed.
 

obscene

Member
You could make it persistent, but give it a Room Start event which says...

if room!=room1 && room!=room2 instance_destroy();
 

chamaeleon

Member
[My answer from your other thread]
Maintain pet state in some controller object that persistent (across all rooms), and create a pet instance in the room you need it when the room is active, and make use of the information in the pet state controller object? In other words, the pet instance is then just to handle the visuals and interaction and as such creating and destroying the instance wouldn't influence the state information. Regardless of which room you are in, presumably the pet would still "exist" (in some deep metaphysical sense), so if you go to a room where there is no pet, and then go back, you'd want the pet to be there, I would imagine. The state information would include what sprites to use, which room the pet is currently in, etc. and you'd read that information and create or update the pet instance as needed.
 
Maintain pet state in some controller object that persistent (across all rooms), and create a pet instance in the room you need it when the room is active, and make use of the information in the pet state controller object? In other words, the pet instance is then just to handle the visuals and interaction and as such creating and destroying the instance wouldn't influence the state information. Regardless of which room you are in, presumably the pet would still "exist" (in some deep metaphysical sense), so if you go to a room where there is no pet, and then go back, you'd want the pet to be there, I would imagine. The state information would include what sprites to use, which room the pet is currently in, etc. and you'd read that information and create or update the pet instance as needed.
Exactly this. You should never store important data in volatile instances, like a player, or in your case, the pet. It's always better to store that data in a persistent control instance, or global variables.
 
A

Alex H

Guest
You could make it persistent, but give it a Room Start event which says...

if room!=room1 && room!=room2 instance_destroy();
Thank you for your response. I tried this by adding a create even to the pet object that says "if room!=rm_home && room!=rm_bathroom instance_destroy();" I also made the pet object persistent. The pet object is still showing up in every room. Any insight?

EDIT: I changed the create even to a room start event. will see what happens
 
Last edited by a moderator:
Top