This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SpencerBeige's profile picture

tm

Started by SpencerBeige, 14 March 2015 - 09:34 PM
SpencerBeige #1
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
Bomb Bloke #2
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.
Quintuple Agent #3
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.