OUR OFFICIAL WEBSITE: https://dsgamemaker.online - ONLINE


WARNING! YOU WILL BE BANNED WITHOUT WARNING PERMENANTLY FOR SPAMMING THE FORUM WITH NON-DSGM RELATED TOPICS & POSTS! - FULLY ENFORCED!!!

NOTICE: ALL members that have NOT logged in once since their activation within 5 days have been and will be deleted!!! LAST UPDATED: 5-1-2022

NOTICE: I will NOT be sending anymore emails confirming your account being activated.. Try to log in and see if your account was activated yet..

ALL accounts MUST be Admin activated due to the server we are on! - More info in the announcements section

Please read announcements section of the forum upon logging in to stay up to date

Side note: Just a reminder, 4.9 and 5.12 are 2 totally different programs. You cannot use 1 app to load projects from the other.

Save File Possible? Examples?

Discussions and support SPECIFICALLY for version 5.12 only
Jdulay
Newbie
Newbie
Posts: 11
Joined: Mon Jan 25, 2021 2:34 pm

Re: Save File Possible? Examples? :SOLVED:

Post by Jdulay »

Hi team.
Hey, guess what, it looks like we've done it!
I got save files working.

I used the code:

fatInitDefault();
Dim Content As String = "Save success success get!"
Write_File(Content, "saveTest.txt")

And it successfully created a new file with that string data.

I was able to successfully open the text file as well.
It looks like we needed that fatInitDefault(); in the beginning.

Good work, everyone. Now we can all have Save Data in our games. I'm still new to use DS Game Maker, so I'm not exactly sure how to take the string data and turn it into usable integer values for the game. I'm not sure how delimiter formating and parsing string to text works in DSGM, so any assistance in say, saving 10 different values, say for item quantity, and save it to text, then turn load it back into the game.
How do we use the values from a global variable as the Content?
Anway, hey, at least we got Saves working.

Well done, team.

Cheers
Jerrel
User avatar
DigitalDesignDude
Appreciated Member
Appreciated Member
Posts: 84
Joined: Sun Aug 16, 2020 6:02 am

Re: Save File Possible? Examples?

Post by DigitalDesignDude »

@Jdulay Glad you figured out how to successfully write text to a file. :)

Looks like finding a way to save and load variable values is the next challenge.

Wish I knew more myself on how that would be accomplished. Hoping that someone with more of a computer science background can share some insight.
Multimedia Developer & Designer and Former DSGM 5.12 User

Created DS Games: BioDie, Fishing the Deep

Email notifications not currently supported on this forum.
Jdulay
Newbie
Newbie
Posts: 11
Joined: Mon Jan 25, 2021 2:34 pm

Re: Save File Possible? Examples?

Post by Jdulay »

DigitalDesignDude wrote: Fri Jan 29, 2021 11:51 pm @Jdulay Glad you figured out how to successfully write text to a file. :)

Looks like finding a way to save and load variable values is the next challenge.

Wish I knew more myself on how that would be accomplished. Hoping that someone with more of a computer science background can share some insight.
I work in C# and Unity, and interpreting data from a saved line of text is quite easy. My approach for some situations is to use comma "," as a delimiter. I get Unity to read a number value from the file until it reaches a ",", and I can then say, "playerMoney = ..." so and so. And then I say, "playerEXP = ..." the next value that comes after that ",".

I assume we are working in C here with DSGM, which I have only minimal experience with. That makes it a real challenge on my side of things. I'm quite busy with work and don't have the time to learn the C necessary to accomplish the same task in C.

Can anyone else weigh in on this?
User avatar
DigitalDesignDude
Appreciated Member
Appreciated Member
Posts: 84
Joined: Sun Aug 16, 2020 6:02 am

Re: Save File Possible? Examples?

Post by DigitalDesignDude »

Good news, it seems I found out how to get saving and loading to work with variables and have provided an example DSGM 5.12 project below. :)

I managed to figure it out by using the same save and load actions code from DSGM 4.9.


The only problem is, it looks like I can only load the save data when the .nds file is running on actual DS hardware (i.e using an r4 card).

When I use an emulator I can't locate the .sav file that's normally created after saving, and variable values are not saved after closing the emulator.

It's possible the .sav file has been created and it's just not where my emulator can find it.

Perhaps someone else can give my example .nds a try and see if it works with their emulator.


DSGM Save And Load Variables Example
https://digitaldesigndude.itch.io/ds-ga ... r-examples
Last edited by DigitalDesignDude on Sun Jun 23, 2024 3:57 pm, edited 1 time in total.
Multimedia Developer & Designer and Former DSGM 5.12 User

Created DS Games: BioDie, Fishing the Deep

Email notifications not currently supported on this forum.
User avatar
Ruffsta
Site Admin
Site Admin
Posts: 170
Joined: Fri May 22, 2020 6:21 am

Re: Save File Possible? Examples?

Post by Ruffsta »

James is currently away.. i can however pass the info/request to him.. i dunno when he'll reply..
DS Games:
BananaCraze / MasterMind / Rock,Paper, Scissors

*strictly a 4.9 user
imadedsgamemaker
Site Admin
Site Admin
Posts: 15
Joined: Thu May 28, 2020 7:06 pm

Re: Save File Possible? Examples?

Post by imadedsgamemaker »

Glad you got something working. You will have to write some C to save specific variables, or use a file for each variable (?). If you're storing numbers you'll have to "cast" the loaded string back to a number. In C try the atoi function for that (just Googled it). I don't think type casting will work (e.g. int x = (int) char) because the char is a pointer not a value. My C is extremely rusty, fyi.

On using multiple variables in a single file, the delimiter approach is 100% the right way to, split with a comma. DSGM uses this method internally a LOT (eg inside the XDS files). It would be cool to bake this into an action - or if easier just the above part (loading a whole file into a integer variable, e.g. to save a high score or last achieved level). Who wants to try it? Check out the existing actions - should be enough inspiration between all of them.
User avatar
DigitalDesignDude
Appreciated Member
Appreciated Member
Posts: 84
Joined: Sun Aug 16, 2020 6:02 am

Re: Save File Possible? Examples?

Post by DigitalDesignDude »

I found some more information on saving and loading variables from looking at the DSGM 5.0 manual and searching the old DSGM forum with Wayback Machine.

From this excerpt in the DSGM 5 manual, it seems DSGM was never able to save and load without actual DS hardware.

Screenshot of DSGM 5 Manual Regarding Saving.png
Screenshot of DSGM 5 Manual Regarding Saving.png (109.1 KiB) Viewed 3688 times


It seems the reason for that is because:
emulation of the NDS doesn’t support the fat library.
as stated in this old tutorial for saving I found on the old forum.

Guide on How to Implement Game Saving by old Forum User
https://web.archive.org/web/20110624001 ... f=6&p=6969


I do not know if saving on emulators will work by using another library, but as a workaround, perhaps people can still use save states to play and save their progress for DSGM games?

I haven't been successful so far with my tests, but maybe someone more experienced with DS emulation may be able to get it to work.

At least should anyone want to make a physical DSGM game, we have an example solution that works on a real Nintendo DS.
Multimedia Developer & Designer and Former DSGM 5.12 User

Created DS Games: BioDie, Fishing the Deep

Email notifications not currently supported on this forum.
Post Reply