thanks :D/>/>
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Lua] Can you program this for me?
Started by mibac138, 25 November 2012 - 05:58 AMPosted 25 November 2012 - 06:58 AM
if example-file exist then
thanks :D/>/>
thanks :D/>/>
Posted 25 November 2012 - 07:16 AM
local file = fs.open('somefile','r')
if file then
local filecontents = file.readAll()
file.close()
end
Something like this?Or if you just wanted to see if a file exists:
if fs.exists('somefile') then
-- stuff
end
Posted 25 November 2012 - 07:28 AM
code number 2 but what doing code number 1 ?
Posted 25 November 2012 - 07:30 AM
The first one is reading files.
Posted 25 November 2012 - 07:30 AM
thanks :D/>/>
Posted 25 November 2012 - 07:43 AM
oh, i forgot how to do if example-file dont exist then
example-file create
example-file create
Posted 25 November 2012 - 08:00 AM
You can't create a file directly, but you can use fs.open('somefile','w')
local filename = 'somefile'
if not fs.exists(filename) then
fs.open(filename, 'w')
fs.close(filename)
end
Posted 25 November 2012 - 08:03 AM
thanks again :D/>/>