Text from file

Place to get help with not working mods / modding interface.
User avatar
Lutra
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Fri Apr 01, 2016 9:22 pm
Contact:

Text from file

Post 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..
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Text from file

Post by daniel34 »

Factorio doesn't support reading files (or anything else in io).

The only interaction possible with files is write_file.
quick links: log file | graphical issues | wiki
User avatar
Lutra
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Fri Apr 01, 2016 9:22 pm
Contact:

Re: Text from file

Post by Lutra »

ah. ok. that buggers thing up a bit. Thanks anyway :D
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
Post Reply

Return to “Modding help”