设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 101|回复: 0

[转载发布] .txt Files Builder/Opener

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-1 22:34:55 | 显示全部楼层 |阅读模式
    Making this script for one of the request here.

    It can be done using eventing alone too, but script makes the management easier.

    For those interested in the eventing side, please check out that link instead.

    Features:

    [1] A simple way to create  .txt files using preset data in the script settings.

    [2] A way to open those .txt file using its default program (eg. notepad/word)

    What is it useful for:

    Great if you want to prevent the lost of your readme.txt and recreate it when it's missing from the game directory. Or when you want to add additional game infos using .txt when the player reach certain stages in the game. eg. special password hints for new game+

    As of the new update, it's now able to check if files exist on a script call, allowing those saved files to act as global save/flags for your game.

    Compatibilities:

    Using new methods in this script so a conflict is unlikely to happen unless another script uses the exact same new method names in their creation.

    Terms of Use:

    Feel free to use it in both commercial & non-commercial project

    Spoiler#==============================================================================# ■ Meow Face Text File Output#------------------------------------------------------------------------------# Create .txt files using the preset data in Settings#==============================================================================# How to Use:# [1] Put this script below Material and above Main# [2] Set up the datas in Settings Area below## Script Call:# txt_save("variable", "filename")## eg. txt_save("DOC1", "Filename.txt")#    will output DOC1 datas in settings to Filename.txt file## open_file("filename")## eg. open_file ("Filename.txt")#    will open Filename.txt file using its default program## check_file("filename")## eg. check_file ("Filename.txt")#    will check if Filename.txt file exist or not and return True/False#   Use this script call in your conditional branches in the script box##==============================================================================module MeowFaceDoc # Do not Remove!#==============================================================================# Settings Area#==============================================================================#------------------------------------------------------------------------------# The folder you want the files to be created# Please use '.' for default game folder#------------------------------------------------------------------------------FOLDER = '.\Ending_Extra' #------------------------------------------------------------------------------# This is where you add your text documents# Add as many new @DOCX as you like (where X = the document number)# You can use "\n" to start a new line, or simply enter a new line below (see example below)#------------------------------------------------------------------------------@DOC1 = "=============Title of Doc=============Line 1Line 2Line 3Line 4Line 5"@DOC2 = "Line 1\nLine 2\nLine 3\nLine 4"@DOC3 = "Happy Kitty dancing in the hallAngry Mole rushing down the hole"#==============================================================================# End of Settings Area# Edit Anything Pass This Line at Your Own Risk!#==============================================================================endclass Game_Interpreter  def txt_save(data, filename)    @text = MeowFaceDoc.instance_variable_get("@#{data}")    Dir::mkdir(MeowFaceDoc::FOLDER) if !Dir.exists?(MeowFaceDoc::FOLDER)    @file = File.join(MeowFaceDoc::FOLDER,filename)    if !File.exist?(@file)      @CreateFile = File.open(@file, 'w')      @CreateFile.puts(@text)      @CreateFile.close      @text.clear    end  end  def open_file(filename)    @file = File.join(MeowFaceDoc::FOLDER,filename)    system %{cmd /c "start #{@file}"} if File.exist?(@file)  end  def check_file(filename)    @file = File.join(MeowFaceDoc::FOLDER,filename)    return true if File.exist?(@file)    return false  endend



    Update:

    24/09/2015 - forgot to add a file check for opening file, it's fixed now

    25/09/2015 - added a way to check if files exist


    本贴来自国际rpgmaker官方论坛作者:MeowFace处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/txt-files-builder-opener.45024/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 14:36 , Processed in 0.141593 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表