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?
Try
Code:
file = File.open("Text", "rb")
file.each_line {|line|
eval(line)
}
file.close
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
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.
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.
Try with this code insteand:
Code:
file = File.open("Text", "rb")
eval(file.readlines)
file.close
I'm closer now.
but It gives me the following error:
line 4: cannot convert array into string
Ohh, sorry, I forget a bit of code:
Code:
file = File.open("Text", "rb")
eval(file.readlines.join)
file.close
Thank you very much. You have been of great support ^^