IndoorMinotaur

Villager
Member
Joined
Oct 10, 2020
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hi! I need to write a text file to the player's "My Games" folder in documents (C:\Users\%userprofile%\Documents\My Games\GameFolder), and my knowledge on how to do this is very lacking.

The purpose of this is to allow integration with other games in the franchise that check for save files and unlock things between them. In order for this to work, it has to write a text file to a static folder with the player's user profile in it. Unfortunately, every bit of information on the subject of writing external text files has been relative to the game location and therefore not quite applicable.

I've looked at a few different plugins and resources and I can't quite find out how to do what I need. Any direction or advise would be appreciated.

Thanks!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,647
Reaction score
15,736
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Requests. Thank you.



This sort of thing usually goes into %appdata%, not into Documents.

Unless your game creates a Documents\MyGames folder, you have no guarantee that it will even exist. I don't have one on Windows 10.
 

IndoorMinotaur

Villager
Member
Joined
Oct 10, 2020
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
[move]Plugin Requests[/move]

This sort of thing usually goes into %appdata%, not into Documents.

Unless your game creates a Documents\MyGames folder, you have no guarantee that it will even exist. I don't have one on Windows 10.
The game that it needs to interface with creates the folder, but frankly the location is less important than it being a fixed location the other titles can point to when necessary.
 

rexie09

Villager
Member
Joined
Apr 4, 2021
Messages
28
Reaction score
10
First Language
English
Primarily Uses
RMMZ
Hello i dont know if you have found any fix yet but you could use

process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share") and store the result in a variable and use that as the home location of the data.
this will always point to the same location depending on the os and with this you can make a folder and add whatever you need into it
 

IndoorMinotaur

Villager
Member
Joined
Oct 10, 2020
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hello i dont know if you have found any fix yet but you could use

process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share") and store the result in a variable and use that as the home location of the data.
this will always point to the same location depending on the os and with this you can make a folder and add whatever you need into it
Hi Rexie, I haven't yet found a solution so I'm grateful for the reply.

What you are describing sounds like it might be helpful, but the execution is a little over my head. I'm guessing darwin is the Mac OS version of win32, but how do I save this as a variable? Do you mean like an in-game variable?
 

rexie09

Villager
Member
Joined
Apr 4, 2021
Messages
28
Reaction score
10
First Language
English
Primarily Uses
RMMZ
Hi Rexie, I haven't yet found a solution so I'm grateful for the reply.

What you are describing sounds like it might be helpful, but the execution is a little over my head. I'm guessing darwin is the Mac OS version of win32, but how do I save this as a variable? Do you mean like an in-game variable?
I meant a variable in JS for example
JavaScript:
const location = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share");

//proceed with code to write to text file using location as the base directory

because assigning it to a game variable would be useless if all you need it for is saving stuff from the game in a localized location with a script
 

Latest Threads

Latest Profile Posts

Finds notes for an old side project... Oh, that's right, the two tracks that sounded really cool and gave inspiration for the big bad in that game... Spends day working on cutscene from old notes, looks okay, now lets slot in the first track... um... I did have those tracks??? It was a year or so ago but I did buy them didn't I?
CA9mtHJ.gif

Everything is really confusing for me
Well, I'm quickly recovering from Covid, but I'm still broke and injured lol. I miss working on my game! I think I've figured out a lore-friendly way to do a tutorial section separate from the main gameplay, but it'll take some scripting know-how. Which I don't have. And can't afford. :p

Forum statistics

Threads
118,582
Messages
1,117,126
Members
155,650
Latest member
RPyro64
Top