283 posts
Posted 14 March 2015 - 10:34 PM
while true do
print("name:color:text")
name = io.read()
color = io.read()
text = io.read()
print(name..":"..color..":"..text)
sleep(1)
file = fs.open(name, "w")
file.writeLine("colors."..color)
file.writeLine(text)
file.flush()
file.close()
term.setCursorPos(1, 1)
term.clear()
end
i would like this to open the file, and write color, text but….everytime i run the program, for example: type in dirt, brown, [blank], the dirt file is nvr created
7083 posts
Location
Tasmania (AU)
Posted 14 March 2015 - 10:37 PM
I'm thinking you're not looking for the files in the correct place. This script will place them on the root of your computer's drive.
113 posts
Location
This page
Posted 14 March 2015 - 11:14 PM
Just an fyi, you don't have to do file.flush(), .close will still save the file and close the handle. .flush is if you want to keep the handle open but save the file (just in-case the user terminates the program, or the script crashes, etc). .flush is good for things like logging programs, or games that save every time you do something.