Posts: 1,019
Threads: 76
Joined: Jan 2010
If I have a txt file called "Text" in my games data folder.
The content of this txt file is:
print "hi"
How can I execute this text file from an in-editor script?
Posts: 1,127
Threads: 43
Joined: May 2009
Try
Code:
file = File.open("Text", "rb")
file.each_line {|line|
eval(line)
}
file.close
Posts: 1,019
Threads: 76
Joined: Jan 2010
Thanks a lot. It works ^^
EDIT:
when i have a whole class with lots of stuff in the txt document, I get the following error:
Syntax error occurred while running script
Posts: 40
Threads: 9
Joined: Sep 2009
That's simple, you have syntax error in the text file. Try copying the script from the text file to the RMXP scripts and run the game, then RMXP will tell you where the syntax error is.
Posts: 1,019
Threads: 76
Joined: Jan 2010
I tried, but I don't get any errors.
So, what I'm trying to do is to have the Scene_Title class in a txt document and load it into the game using the code charlie provided.
Posts: 40
Threads: 9
Joined: Sep 2009
Try with this code insteand:
Code:
file = File.open("Text", "rb")
eval(file.readlines)
file.close
Posts: 1,019
Threads: 76
Joined: Jan 2010
I'm closer now.
but It gives me the following error:
line 4: cannot convert array into string
Posts: 40
Threads: 9
Joined: Sep 2009
Ohh, sorry, I forget a bit of code:
Code:
file = File.open("Text", "rb")
eval(file.readlines.join)
file.close
Posts: 1,019
Threads: 76
Joined: Jan 2010
Thank you very much. You have been of great support ^^