Group: Member
Posts: 11
Type: Developer
RM Skill: Skilled
Nice code guys! I'm going to save it for the chance I have lag in later maps (or this one I'm currently working on once I'm done).
I noticed that the read function to open the game.ini is extremely similar to, say , PHP. Just an observation there. Is it also possible then to use a script to read and write to a file, just by changing the r to a w (I think that's the syntax)? I'm not sure if this is useful or not, but I always like the idea of being able to save... something... to a text file for later use.
__________________________
Busy busy busy... Father, band member, rpg developer, song writer, fiction writer, full-time job... phew!!
Currently working on Savage for RPG Maker VX. See profile for details.
Use Ruby File for opening/closing the file, as if you were the Explorer.exe Use Ruby IO for editing the file, as if you were notepad
So to make a file
CODE
if not File.exists?("Hello_World.txt") file = File.new("Hello_World.txt", "w") file.write("Starting\n") file.close end
Appending
CODE
if File.exists?("Hello_World.txt") file = File.new("Hello_World.txt", "a") file.write("Beaten Dungeon 1\n") file.close end
Reading
CODE
if File.exists?("Hello_World.txt") file = File.new("Hello_World.txt", "r") @file_text = file.read file.close end p @file_text p @file_text.include?("Beaten Dungeon")
Or something like that
Moderator Time If you have any future questions about RGSS or ruby, our rules say that asking about it here counts as Unsolicited Spam, so I recommend asking in the RGSS Script Support
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.