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

[Question][Error?] fs API assistance

Started by Zalerinian, 26 May 2012 - 12:03 PM
Zalerinian #1
Posted 26 May 2012 - 02:03 PM
I'm trying to make a program that will write to a file in a directory, and it mostly works. However, when i go to open the file, instead of having the text that was set to go into the file, it inputs something like:


table: 5828f4f5

Every time i run the program to input the text, the format stays the same but the code changes. The program i'm using is very, VERY simple, and doesn't involve tables at all, so i'm puzzled as to why its doing that. My test program is as follows:


f1 = fs.open("file", "w")
f1:writeLine()
f1:close()

It also occurs when using

f1:write()

This isn't a life or death situation, so I don't need responses the second you read this, but any help would be appreciated :)/>/>
my_hat_stinks #2
Posted 26 May 2012 - 03:11 PM
Looks to me like you're trying to write a table rather than the values in the table
Zalerinian #3
Posted 26 May 2012 - 04:18 PM
Turns out that the fs api isn't the best option for making an d writing to files. The io API is much easier to do it with, so i'll be using that now.
MysticT #4
Posted 26 May 2012 - 06:09 PM
You have to use it like:

local file = fs.open("path", "w")
if file then
  file.write("Some text")
  file.close()
end
Note that it uses . instead of :