59 posts
Location
Places, Ukraine
Posted 03 December 2016 - 06:55 AM
Hello,
I'm not sure if this is just a bug or if the feature was removed. If you were to use my following code
http://pastebin.com/7kcbpydPyou would be able to set the variable j to the second line of the file. However that is no longer the case, as of right now I get 'Hello1' instead of 'Hello2'. I seen on the wiki the description of the function has changed. If this has been removed, how do I use something that worked like the previous?
756 posts
Posted 03 December 2016 - 07:18 AM
readLine never worked like this, you must be confusing it with something else.
Whatever the purpose you have in mind, you can load the whole file easily into a table.
local f = fs.open("test1", "r")
local lines = {}
for line in f.readLine do
lines[#lines+1] = line
end
And index your line number from the table, in this case, lines[2] will contain "Hello2".
59 posts
Location
Places, Ukraine
Posted 03 December 2016 - 07:32 AM
readLine never worked like this, you must be confusing it with something else.
Whatever the purpose you have in mind, you can load the whole file easily into a table.
local f = fs.open("test1", "r")
local lines = {}
for line in f.readLine do
lines[#lines+1] = line
end
And index your line number from the table, in this case, lines[2] will contain "Hello2".
I'm very sure it worked like this at one point. I've used it before like I posted and it worked like I posted.
726 posts
Location
Rem is best girl
Posted 03 December 2016 - 08:29 AM
theres no argument in readLine to specify what line and it never has. Maybe you were using an api that modifys it :P/>
1583 posts
Location
Germany
Posted 03 December 2016 - 01:03 PM
Not even the first entry of the wiki contains that function signature you used in the snippet above.
http://computercraft.info/wiki/index.php?title=Fs.open&oldid=835
463 posts
Location
Star Wars
Posted 03 December 2016 - 08:33 PM
readLine reads the line until a \n or till the end and jumps the 'read cursor' behind the \n (if \n is on the fourd letter, the position is 5).
In normal Lua, you would use handle.seek(10) (I am not sure) to set the cursor position to 10.