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

I need some help.

L

lnb819

Guest
Alright so im making an RPG and I need the rooms to save. I need it once you collect a key you cant collect again. When i go back to that room the key is there again. How do I make it save the room so people cant collect the key again.
 

samspade

Member
There are two levels to this. First handling the issue within a single 'run' of the game and second handling it over multiple 'runs'.

Within a single run you need to:
  • Make a variable, a global variable would be easiest, such as global.key_collected.
  • Set the variable to false at the start of the game
  • only spawn the key if the variable is false
  • once you collect the key, change the variable to true
If you want it to persist through multiple runs of the game (which presumably you will):
  • Make a variable, a global variable would be easiest, such as global.key_collected.
  • After making the variable, load it in, with a default of false
  • Set the variable to false at the start of the game
  • only spawn the key if the variable is false
  • once you collect the key, change the variable to true
  • save the variable state upon game exit, or change, or whenever you want
To understand more about saving and loading, look up some tutorials on YouTube. I would suggest starting with Shaun Spalding's ini tutorial as it is probably the easiest and will work for what you're doing.
 
Top