MFGG Forums
  • Home
  • Members
  • Help
  • Search
MFGG Main Site MFGG Forums MFGG Developer Discussion v
« Previous 1 … 12 13 14 15 16 Next »
GM Studio 2's save system is bugging me
MFGG Forums MFGG Developer Discussion v
« Previous 1 … 12 13 14 15 16 Next »
GM Studio 2's save system is bugging me
MFGG Forums MFGG Developer Discussion v
« Previous 1 … 12 13 14 15 16 Next »
GM Studio 2's save system is bugging me
Mark All Posts Read Today's Posts

GM Studio 2's save system is bugging me
United States VinnyVideo
Can't have an avatar without a Shy-Guy
Site Developer
Main Site Moderator Site Developer/Webmasters Wiki SysOp Big Help Submitter Super Reviewer (2) Wiki Contributor Sprite Comp Runner-Up Minigame Comp Winner Minigame Comp Runner-Up Minigame Comp Top 5 (3) Music Comp Winner Music Comp Runner-Up Music Comp Top 5 (2) Drawing Comp Top 5 Game of the Month Winner NCFC Contributor (4) Secret Santa (5) MFGG 17th Anniversary MFGG 18th Anniversary MFGG 19th Anniversary Ye Olde MFGGe Retro Game Jam Participant MFGG Awards 2010 Winner MFGG Awards 2011 Winner MFGG Awards 2012 Winner MFGG Awards 2013 Winner MFGG Awards 2014 Winner MFGG Awards 2015 Winner MFGG Awards 2017 Winner (3) MFGG Awards 2019 Winner MFGG Awards 2024 Winner
#1
01-13-2018, 11:09 AM
I used similar code to save files in GM 8, but when I use it in GM Studio 2, it won't save a file in the location that the ApplicationData environment variable points to. It seems that the AppData environment variable works a little differently in newer versions of GM, so what I am doing wrong here?

Code:
if file_exists(environment_get_variable("ApplicationData")+"\gamename.sav")
    file_delete(environment_get_variable("ApplicationData")+"\gamename.sav");
    
var file = file_text_open_write(environment_get_variable("ApplicationData")+"\gamename.sav");

var savelist = ds_list_create();
ds_list_add(savelist, global.boringVariableName);

var savestr = ds_list_write(savelist);
file_text_write_string(file, savestr);
ds_list_destroy(savelist);

file_text_close(file);

  ↳
Miles
hi
Members
Submitter Iso Collab Contributor Minigame Comp Winner Minigame Comp Runner-Up Drawing Comp Top 5 Special Comp Top 5 Game of the Month Winner NCFC Contributor MFGG 18th Anniversary Ye Olde MFGGe Retro Game Jam Participant MFGG Awards 2011 Winner MFGG Awards 2012 Winner MFGG Awards 2013 Winner
#2
01-13-2018, 12:07 PM (This post was last modified: 01-13-2018, 12:22 PM by Miles.)
You can probably shave off all the environment variable stuff and just use direct filenames as the strings.

Starting in Game Maker Studio they sandboxed the environment, meaning you can only save to a certain predetermined spot unless you get around it with an extension or directly ask the user for a directory with certain functions. It shoves game saves in %localappdata%\<Game Name>. If you want a specific single directory rather than the forced one, you'll want to track down an extension to do so - this one may or may not help? (Seemed to be the only free one of this kind that claimed GMS2 compatibility, but I can't test this myself.)

https://docs2.yoyogames.com/source/_buil...ystem.html - This explains it infinitely better than I can.
[-] The following 4 users Like Miles's post:4 users Like Miles's post
  ↳ DustinVG, VinnyVideo, Willsaber, WreckingPrograms
Canada Syaxamaphone
Cute!
Members
Submitter Iso Collab Contributor (2) Sprite Comp Runner-Up Minigame Comp Winner Minigame Comp Runner-Up (2) Drawing Comp Runner-Up Drawing Comp Top 5 Super Comp Winner Super Comp Runner-Up Super Comp Top 5 Game of the Month Winner NCFC Contributor Secret Santa Holiday Tree (2) Super Rolling Mario Good Citizen MFGG 17th Anniversary MFGG 18th Anniversary MFGG Awards 2014 Winner MFGG Awards 2016 Winner MFGG Awards 2017 Winner
#3
01-13-2018, 01:34 PM (This post was last modified: 01-13-2018, 01:36 PM by Syaxamaphone.)
Yeah Miles pretty much answered your question. GMS file functions by default can read the application's folder and read/write its appdata folder. It will actually always attempt to read the game's folder first. If it doesn't find the file, it moves to check appdata next.

So if you want to save just indicate the filename without a directory and it will automatically save/load from the game's appdata folder (which it will automatically make for you when it runs).

To access appdata, you can use Windows+R to open the run command and then type in 'appdata'. You'll then find your game's folder in appdata/local/<name of game>.
My games | My twitter | My stream | Sprites Unlimited

[Image: A1BH1oG.png]
[-] The following 3 users Like Syaxamaphone's post:3 users Like Syaxamaphone's post
  ↳ DustinVG, Miles, VinnyVideo
United States VinnyVideo
Can't have an avatar without a Shy-Guy
Site Developer
#4
01-17-2018, 02:23 PM
@Miles @Syaxamaphone Thanks for the insight. Upon further review, the game did save my file - just not in the location I was expecting!
Course clear! You got a card.

[Image: CourseClear.gif]


  ↳
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
Forum Jump:

Mario Fan Games Galaxy - Powered by MyBB | MFGG Staff | Contact Us

Linear Mode
Threaded Mode