Ok, I could either give you bits of my API or I could give you a "kinda" method :)/>/>
Ill try the "kinda"
if fs.exists("FirstStartPass") then dofile("FirstStartPass") else write("Password: ") Password = read() Heh = io.open("FirstStartPass", "w") Heh:write(Password) Heh:close() end
This makes a new file called FirstStartPass.
If I quoted my API at you it could be done inside the file.
But idk if there is any short way to get that in the first line.
If you are interested in the API tho.
Look at this.
function removeLineNo(filename, ...) -- Say the file you want removed. Then the line numbers of the lines you want removed.
local LinesRemove = {...}
local fp = io.open( filename, "r" )
local content = {}
local i = 1
for line in fp:lines() do
content[#content+1] = line
i = i + 1
end
fp:close()
for n=1,#LinesRemove do
table.remove(content,LinesRemove[n])
for e=1,#LinesRemove do
LinesRemove[e] = LinesRemove[e]-1
end
end
local fp = io.open( filename, "w" )
for i = 1, #content do
fp:write( string.format( "%sn", content[i] ) )
end
fp:close()
end
function insertLine(file, lineno, Insertline) -- say the file, Then the line number. Then the line to be inserted.
local lolol = io.open(file, "r")
local content = {}
local i = 1
for line in lolol:lines() do
if i == lineno then
content[#content+1] = Insertline
i = i + 1
end
content[#content+1] = line
i = i + 1
end
lolol:close()
local lolol = io.open( file, "w" )
for i = 1, #content do
lolol:write( string.format( "%sn", content[i] ) )
end
lolol:close()
end
with the api you can do it with
write("Password: ") Bla = read() insertLine("startup", 2, Bla)removeLineNo("startup", 1)