Jump to content

Recommended Posts

I need a script that creates a .txt file in any folder I specify, and allows me to put whatever text I want in it. It needs to be called through a script call. My plan is to make a character who hints at locations, and breaks the fourth wall referencing a folder, like, say, graphics folder, and a txt file appears in there containing clues.

Share this post


Link to post
Share on other sites

 

 

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  def make_file(path, string)
    File.open(path, "a+") do |file|
      file.puts string
    end
  end
end 

 

 

This will make a file if the file doesn't exist, if it does exist it adds text to the bottom of the file.

 

all you have to do is make a script call "make_file(path, string)"

 

path is where the file's path examples:

text.txt

is in the main folder

Graphics/text.txt

is in the graphics folder.

 

If the folder doesn't exist, it will not make the folder, you will get an error.

 

string is just the text you want to put inside the file, you can use \n to create a new line in the text.  As for the extension you can put w.e. you want, but you should do .txt so they can just double click and it opens with notepad

Share this post


Link to post
Share on other sites

If you want to create the text and in Graphics folder and you encrypt the game, it won't work. Obviously, where you can see the Graphics folder?

Share this post


Link to post
Share on other sites

Oh, ahahha, sorry, had a brainfart there. xD, it won't be encrypted. Anyway, I'ma give that a run, Quasi. :3. Thanks for doing this, xD. I didn't expect to get a reply so fast.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted