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

Loading a file

U

Ukaygee

Guest
So, in my game, when I press a button, it loads the game, using game_load. I have an object which is supposed to set a variable to true when I load the game. To do this, i tried putting this in the button when I click it:
Code:
with(opsmgr)
{
    hascontrol = true;
}
Now, of course this isn't going to work because when you load the game, the opsmgr doesn't run the code. Is there a way I can get the opsmgr to perform the code above when I load the game? I can't think of anything

Anyone? I need help :(
 
Last edited by a moderator:

Humayun

Member
I can't grantee but try loading game first and then setting the variable like this:
game_load(file);
with (opsmgr)
{
hascontrol = true;
}
 

TsukaYuriko

☄️
Forum Staff
Moderator
You're breaking the boundaries of game_load. Running code that affects the game state after loading the game is not possible. It's not what the function was made for (which is quickly loadable checkpoints of simple games without writing your own saving and loading mechanism).

The proper solution would be to write your own saving and loading mechanism, as this will give you full control over what loads when, what gets overwritten afterwards and what stays the way it is before loading.

A sort-of-hackish-thing-that-I-refuse-to-call-solution would be executing the code you want to execute when loading... right before saving the game. This will cause whatever changes you're trying to make to be saved to the save file, and thus read when loading the game. This may or may not conflict with what you're trying to do, and either way, this even being a concern is just another indicator that you should be making your own system as your project has grown outside of the boundaries the basic saving and loading can provide.
 
U

Ukaygee

Guest
You're breaking the boundaries of game_load. Running code that affects the game state after loading the game is not possible. It's not what the function was made for (which is quickly loadable checkpoints of simple games without writing your own saving and loading mechanism).

The proper solution would be to write your own saving and loading mechanism, as this will give you full control over what loads when, what gets overwritten afterwards and what stays the way it is before loading.

A sort-of-hackish-thing-that-I-refuse-to-call-solution would be executing the code you want to execute when loading... right before saving the game. This will cause whatever changes you're trying to make to be saved to the save file, and thus read when loading the game. This may or may not conflict with what you're trying to do, and either way, this even being a concern is just another indicator that you should be making your own system as your project has grown outside of the boundaries the basic saving and loading can provide.
Thanks for your help, I would write my own system, but I'm not really sure how. I would try using ini files, but if I was to try to make my own saving system, I would have to save and load the state of 2500 objects... I would also try doing your sort-of-hackish-thing-that-I-refuse-to-call-solution, but that wouldn't really work very well.

Nvm I got your sort-of-hackish-thing-that-I-refuse-to-call-solution working, thanks frendo
 
Last edited by a moderator:

Joe Ellis

Member
you could use buffers, i use them for anything that needs to be saved, and doing 2500 is fine if you loop it
 
Top