• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED Unable to write to files

(v2.3.3.437 Windows non-steam version)
Hi,
I'm trying to export a json string into a .json file, but nothing is happening and no file is written to my "working_directory" folder.
Apparently none of the file writing functions seems to be working for me.
Heres what i've tried so far:
  1. Checked if the json var isn't empty using the debugger.
  2. I checked the "working_directory" folder that is created in %localappdata%.
  3. Tried compiling the game exe to see if that helps.
  4. I also tried writing a simple string "hello" to a .ini file.
  5. Made an empty file with the name "tiledata.json" and writing to it but nothing is happening.
  6. I used both the YYC compiler and the VM one.
heres my code:
GML:
        var map = ds_map_create();
        ds_map_add(map, "tile", tileInfo);

        var json = json_encode(map);
        var theJsonFile = file_text_open_write("tiledata.json");
        file_text_write_string(theJsonFile, json);
        file_text_close(theJsonFile);

        ds_map_destroy(map);
Maybe i'm missing something obvious. Appreciate any insight or help in that matter.
Cheers.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Is anything actually executing that code? Verify this by outputting a debug message at the end.

Are you checking the correct directory? Verify where the files are written to. You can check and specify this in the game settings (Ctrl+T -> save location). If you're unsure whether you're checking the correct directory, post it here.
 
Is anything actually executing that code? Verify this by outputting a debug message at the end.

Are you checking the correct directory? Verify where the files are written to. You can check and specify this in the game settings (Ctrl+T -> save location). If you're unsure whether you're checking the correct directory, post it here.
I checked the save location like you said and apparently it is a different path than working_directory !
This is very misleading and i really don't get what this variable is even for..
Is there any way to get the save location in a code?

Anyways this solved my problem, thank you very much!
 

TsukaYuriko

☄️
Forum Staff
Moderator
That would be the award-winningly named game_save_id, which is a directory path, not a number as one might think at a first glance...
 
Top