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,742
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 Posts

Latest Profile Posts



I tried to make a face portrait.
it's the first ever time I try something like this, hope it came out decently even if it was my first.
Sometimes I wanna thanks to my past self for learning how to draw _:3

what people think game making is like:
1643382734530.png
What game making is actually like:
1643382928058.png
SA72K_ATTACK.gifThe boss of an "illegal" cybercafe, leading his little gang fighting against an authoritarian government that censors games. I wonder which side will players pick. :kaojoy:

Forum statistics

Threads
118,797
Messages
1,118,752
Members
155,966
Latest member
stelarbree
Top