How can you make the function File:Read() to return only one line

Well you know … https://wiki.garrysmod.com/page/File/Read

If the file contents are:

aaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbb
ccccccccccccccccccc

On the first iteration to “aaaaaaaaaaaaaaaa”, second “bbbbbbbbbbbbbbbb” and so on …

Is it maybe ( I do not have access to Gmod right now … ):



local Line = "X" -- Just to be something
  while(Line) do
    print(F:Read())
  end


… to print the lines sequentially ?

just split it up, lines:Split("
") after reading everything

-snip-

Guys, reading the whole file is one big bad idea… Imagine when the database grows like hell ( which it is :smiley: )

Now I’m reading it symbol by symbol, bit it’s slow …

https://raw.githubusercontent.com/dvdvideo1234/TrackAssemblyTool/master/data/trackassembly/dsv/sv_TRACKASSEMBLY_PIECES.txt

glua doesn’t have file handle support
and you should probably consider a better storage method

Are you talking about handle ( which is a number), file pointer or a file object.
I do recall that glua supports the last two. How can I then easily call File:Read(1) ??
File handle as it is I think it’s not applicable for glua ( as you cannot call 42:Read(1) ),
but this does not show how it is connected to the functionality reading one line at a time ??

Yes maybe, CSV ( comma separated values ) seems the better way so far. If you got any Ideas,
I am listening. :smiley:

file handles, as in other languages where you can manually read x amount of bytes or whatever, does not exist in glua, only in “pure” lua

use an sql database, if you’re going to distribute it, it can load once from the file to insert into the db on startup to reduce load