Reputation: 117
I execute the code below but it doesn't create an output file (at least on the directory where the *.lua is)
file = io.open("output.txt","w")
io.output(file)
io.write("hello, reader!")
io.close(file)
I am using ZeroBrane Studio on Windows, if that helps
Upvotes: 0
Views: 88
Reputation: 837
The file will be created in the project directory you're currently in.
You can click the button Set project directory from current file
in ZBS when you have your lua
file open.
By the way, another cleaner looking way to write to a file would be using methods on the file instead, like
file = io.open("output.txt","w")
file:write("hello, reader!")
file:close()
It does the same thing, looks prettier though.
Upvotes: 2