
Forum




Input More Than First Line
9 replies





1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
local a = 0;
local LINE_VALUE = "";
local LINE_TO_READ = 5;
for lines in io.lines(FILE_PATH) do
a = a + 1;
if a == LINE_TO_READ then
LNE_VALUE = lines
end
end
1
for line in io.lines("save.txt") do
or read the entire content of the file and split it at each newline ("\n"). But that would require writing a string:split function first since it isn't included in the Lua standard library...
Banaan has written
You could use io.lines in a for loop:
or read the entire content of the file and split it at each newline ("\n"). But that would require writing a string:split function first since it isn't included in the Lua standard library...
1
for line in io.lines("save.txt") do
or read the entire content of the file and split it at each newline ("\n"). But that would require writing a string:split function first since it isn't included in the Lua standard library...
Would be great if somebody made a non-standard library...



Sunny Autumn has written
Would be great if somebody made a non-standard library...
Banaan has written
You could use io.lines in a for loop:
or read the entire content of the file and split it at each newline ("\n"). But that would require writing a string:split function first since it isn't included in the Lua standard library...
1
for line in io.lines("save.txt") do
or read the entire content of the file and split it at each newline ("\n"). But that would require writing a string:split function first since it isn't included in the Lua standard library...
Would be great if somebody made a non-standard library...
I think Lee's AMX2D includes quite a lot of useful functions for string/table manipulation (core/string.lua and core/table.lua). Though one can find (or write themselves) better alternatives (there are many ways to reach the same result, e.g. about 15 different trim functions) for most of his functions, I think it's a really useful addition.
It's a shame he used string.trim rather than string:trim though...



