IndoorMinotaur

Villager
Member
Joined
Oct 10, 2020
Messages
9
Reaction score
2
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
45,536
Reaction score
16,423
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
2
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
2
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 Posts

Latest Profile Posts

Spend more time building up what you like, and stop tearing down things you don't. If you only tear stuff down, nobody will get to enjoy anything.
Work, work. Streaming in 20 minutes or so.
Finnuval wrote on fizzly's profile.
Cool.looking avatar ;)
So... looks like I'm NOT gonna be a parent... :(
JR.png

Why are characters in Art Deco so hard to do...

Forum statistics

Threads
129,930
Messages
1,206,312
Members
171,129
Latest member
rocky_lane
Top