じ☆ve冰风 发表于 2026-7-30 15:11:41

ozu_File – Create and manipulate files from within the game itself!

ozu_File 1.2
by ozubon

Introduction
Using Node.js' file system module can be a hassle. Getting it to work both in playtest and after deployment seems to be something people are having trouble it. This aims to give some easy to use functions as tools for manipulating the game folder's files using Node.js – both for people who've tried implementing the .fs module and failed and for anyone with basic script call knowledge who wants to play with files.

Does not work on mobile!

Features
This plugin allows you to do things with your game files and folders from within the game itself.

[*]file.exist will check whether a file exists or not
[*]file.write will write or overwrite a file with the text you enter
[*]file.append will add text to an already existing file
[*]file.read will read a file and output its contents as text
[*]file.rename will rename a file to the filename you enter
[*]file.erase will permanently delete a file
How to use
Spoiler: file.existfile.exist
Checks if a file in your game folder exists or not.
Intended for the conditional branch script box.
                Code:       
file.exist("path", "file.type")

"" for path means the main game folder, "" for file checks if folder exists

These all return TRUE:
                Code:       
file.exist("", "index.html")

file.exist("data", "")

file.exist("img/system", "Window.png")



This returns FALSE unless it exists:
                Code:       
file.exist("asdf/gh", "jkl.txt")



Screenshot example:


Spoiler: file.writefile.write
Writes a new file with the desired data.
Intended for script calls.
                Code:       
file.write("path", "file.type", "stuff")

"" for path means the main game folder, the rest is required.

Some examples:
                Code:       
file.write("", "tanoshindekudasai.txt", "Arigato gozaimasu")

                Code:       
file.write("data", "test.json", "Can it write to JSON?")



Screenshot example:


Spoiler: file.appendfile.append
Same as file.write but writes to the end of an existing file instead of overwriting it.
Intended for script calls.
                Code:       
file.append("path", "file.type", "new stuff")

"" for path means the main game folder, the rest is required.

Some examples:
                Code:       
file.append("", "tanoshindekudasai.txt", "!!!")

                Code:       
file.append("data", "test.json", " Yes.")



Screenshot example:


Spoiler: file.readfile.read
Reads a file and outputs a string of what's in it.
Intended for conditional branches and setting variables.
                Code:       
file.read("path", "file.type")

"" for path means the main game folder, the rest is required.

This will return TRUE in a conditional branch (if tanoshindekudasai.txt is exactly "Arigato gozaimasu!!!"):
                Code:       
file.read("", "tanoshindekudasai.txt") === "Arigato gozaimasu!!!"



Using Control Variables, set a variable to
                Code:       
file.read("", "tanoshindekudasai.txt")

and the variable will be set to "Arigato gozaimasu!!!" or whatever tanoshindekudasai.txt contains.


Screenshot example:


Spoiler: file.renamefile.rename
Renames a file, careful not to rename important files.
Intended for script calls.
                Code:       
file.rename("path", "file.type" "new name.type")

"" for path means the main game folder, the rest is required.

Some examples:
                Code:       
file.rename("", "tanoshindekudasai.txt", "ieie.txt")

                Code:       
file.rename("data", "test.json", "johnromero.json")



Screenshot example:


Spoiler: file.erasefile.erase
Do not use this one unless you know what you're doing!
Permanently deletes a file, be VERY careful not to erase important files.
Intended for script calls.
                Code:       
file.erase("path", "file.type")

"" for path means the main game folder, the rest is required.

Some examples:
                Code:       
file.erase("", "ieie.txt")

                Code:       
file.erase("data", "johnromero.json")



Screenshot example:



Terms of use
You don't have to credit me but I'd appreciate it!
For commercial use, you gotta credit me!

Plugin
https://raw.githubusercontent.com/ozubon/tidbits/master/ozu_File.js
Right-click link -> Save As

Credit
ozubon
Kino for this guide


本贴来自国际rpgmaker官方论坛作者:ozubon处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/ozu_file-create-and-manipulate-files-from-within-the-game-itself.120076/
页: [1]
查看完整版本: ozu_File – Create and manipulate files from within the game itself!