Page 1 of 1

Text from file

Posted: Fri Apr 08, 2016 10:55 am
by Lutra
i'm using this to get text from files to be passed back to routines that print the text. but it doesn't work- "control.lua:27: attempt to index global 'io' (a nil value)". this is the code:

function GetTextFromFile(filename)
--defines the variable to hold the text(what will be returned)
local text
local textfile
--opens a text file using the name passed as a parameter
textfile = io.open (filename, "r")
--sets the text variable to what is in the file
text = io.read()
--closes the file
io.close(textfile)
return text
end

can anyone help? i'm pretty sure io.open is the correct command..

Re: Text from file

Posted: Fri Apr 08, 2016 10:59 am
by daniel34
Factorio doesn't support reading files (or anything else in io).

The only interaction possible with files is write_file.

Re: Text from file

Posted: Fri Apr 08, 2016 11:03 am
by Lutra
ah. ok. that buggers thing up a bit. Thanks anyway :D