Forgot?

Register
1 ·
GM 8 Save Question
Never change your avatar
Posts: 3154
Status: Offline
Group: Admin
Member: #1
Now that I have a small quantity of that mythical substance known as "free time," I decided to go back and fix a couple of pesky glitches in ROTW, including the "missing Red Coin" and "fall through the dolphins" problems. The last bug is the "music looping over itself" glitch, which can only be fixed by redoing the save system. At present, ROTW uses GM's built-in save system, which is infamously buggy and isn't fully compatible with the audio DLL.

So, what's the best way to take save the variables from a bunch of objects on the map screen? I know some of you have more experience than I do when it comes to designing save systems in GM, so any help would be awesome.
Course clear! You got a card.
Posts: 766
Status: Offline
Group: Admin
Member: #12
I have one idea, but it depends on some things. Do any objects get created or destroyed? Are the things that need saving going to have instance IDs that do not change?

What exactly do you want (and not want) to do when saving?
Never change your avatar
Posts: 3154
Status: Offline
Group: Admin
Member: #1
Miles
Do any objects get created or destroyed?

No.

Miles
Are the things that need saving going to have instance IDs that do not change?

Yes. The instance IDs will never change.

Miles
What exactly do you want (and not want) to do when saving?

I only need to be able to save two sets of things:

1. Global variables, which are pretty simple
2. Properties of objects on the map screen - level icons and the Mario object on the map
Course clear! You got a card.
Posts: 766
Status: Offline
Group: Admin
Member: #12
Incoming wall of confusion. I imagine there are examples out there somewhere that do it better/smarter/less complicated than I do, but here's what I came up with in about 15 seconds (and typed up in about twice as many minutes).

How anti-cheaty do you want it? If you don't have a particularly no-fun-allowed attitude, the global variables could just go easily in an INI file.

The method I thought of for the map screen objects was to have some system object keep a ds_grid and a size variable. X would be instances, Y would be whatever variable(s) were in those instances (including their id).

To gather data for saving, maybe do something like this, assuming you already defined your grid DS_MapSave and counter MapSaveSize.
MapSaveSize=0; with obj_mapmario {  MapSaveSize+=1;  ds_grid_resize(DS_MapSave,MapSaveSize,6);//6 should instead be whatever the max number of vars you'll be saving from any one object is  ds_grid_set(DS_MapSave,MapSaveSize,0,id);  ds_grid_set(DS_MapSave,MapSaveSize,1,x);  ds_grid_set(DS_MapSave,MapSaveSize,2,y);  } with obj_maptile {  MapSaveSize+=1;  ds_grid_resize(DS_MapSave,MapSaveSize,6);//see above remark  ds_grid_set(DS_MapSave,MapSaveSize,0,id);  ds_grid_set(DS_MapSave,MapSaveSize,1,Completed);  ds_grid_set(DS_MapSave,MapSaveSize,2,CanUp);  ds_grid_set(DS_MapSave,MapSaveSize,3,CanDown);  ds_grid_set(DS_MapSave,MapSaveSize,4,CanLeft);  ds_grid_set(DS_MapSave,MapSaveSize,5,CanRight);  }


For saving all that to a file, set a variable to ds_grid_write(DS_MapSave) and save that string to whatever ini key you want.

And for loading, if the ini key exists, there's ds_grid_read(grid_id,string) where string is the string you saved before, after which you iterate through the grid using its width (ds_grid_width(DS_MapLoad)) as a counter. Something like this would go inside the iterator code:
ObjID=ds_grid_get(DS_MapLoad,InstCounter,0); if instance_exists(ObjID) with ObjID switch object_index { case obj_mapmario:  x=ds_grid_get(DS_MapLoad,InstCounter,1);  y=ds_grid_get(DS_MapLoad,InstCounter,2);  break; case obj_maptile:  Completed=ds_grid_get(DS_MapLoad,InstCounter,1);  //etc  break; }


...This probably makes much more sense in my head than it does here. I can do an example-a-ma-bob if you want. Also, none of that code was tested, I just kind of wrote that from what I guessed would work, other than looking up the function arguments in GM8 itself.
Never change your avatar
Posts: 3154
Status: Offline
Group: Admin
Member: #1
Thanks for your help. That basically makes sense - I'll just need a bit of time to work out the details of making it happen. If you'd like to make an example, that would be cool (and let me know if you need the original .GMK - I'd be OK with letting you see it).

For my own reference, here's what I'll need to save for the Mario object and global variables:



SnS data is stored in a separate file and does NOT need to be saved here.

As for the levels themselves, I also need to be able to store a variable for whether the player has found all the red coins. This might require some small adjustments to the way the map icons work, but it shouldn't be anything too drastic. The hardest part will be adjusting the map blocker objects that prevent you from passing levels you haven't completed.
Course clear! You got a card.
-/+
Users Viewing This Topic
1 ·