Posted 19 December 2012 - 03:30 AM
i got no errors it's simple not deleting
here is my code:
list = fs.list("myPrograms")
fs.makeDir("updater")
progs = {}
version = {}
for number,programs in pairs(list) do
tostring(number)
times_loop = tonumber(number)
progs[number] = programs
end
for i = 1, times_loop do
print(progs)
end
function pastebin()
getVersion()
times_readLine = 1
for i = 1, times_loop do
file2 = fs.open("updater/pastebin", "r")
for a = 1, times_readLine do
file2.readLine()
end
times_readLine = times_readLine + 2
shell.run("pastebin", "get", tostring(file2.readLine()), "updater/"..progs)
file3 = fs.open("updater/"..progs,"r")
file3.readLine()
versionNew = tonumber(file3.readLine())
print(versionNew)
print(version)
if versionNew < version then
if versionNew == version then
shell.resolve()
fs.delete("/updater/"..progs)
elseif
versionNew > version then
shell.resolve()
fs.delete("/myPrograms/"..progs)
fs.copy("/updater/"..progs, "/myPrograms/",progs)
shell.resolve()
fs.delete("/updater/"..progs)
end
end
end
end
function getVersion()
for i =1, times_loop do
file = fs.open("myPrograms/"..progs,"r")
file.readLine()
version = tonumber(file.readLine())
print(progs.." v"..version)
end
end
pastebin()
here is my code:
list = fs.list("myPrograms")
fs.makeDir("updater")
progs = {}
version = {}
for number,programs in pairs(list) do
tostring(number)
times_loop = tonumber(number)
progs[number] = programs
end
for i = 1, times_loop do
print(progs)
end
function pastebin()
getVersion()
times_readLine = 1
for i = 1, times_loop do
file2 = fs.open("updater/pastebin", "r")
for a = 1, times_readLine do
file2.readLine()
end
times_readLine = times_readLine + 2
shell.run("pastebin", "get", tostring(file2.readLine()), "updater/"..progs)
file3 = fs.open("updater/"..progs,"r")
file3.readLine()
versionNew = tonumber(file3.readLine())
print(versionNew)
print(version)
if versionNew < version then
if versionNew == version then
shell.resolve()
fs.delete("/updater/"..progs)
elseif
versionNew > version then
shell.resolve()
fs.delete("/myPrograms/"..progs)
fs.copy("/updater/"..progs, "/myPrograms/",progs)
shell.resolve()
fs.delete("/updater/"..progs)
end
end
end
end
function getVersion()
for i =1, times_loop do
file = fs.open("myPrograms/"..progs,"r")
file.readLine()
version = tonumber(file.readLine())
print(progs.." v"..version)
end
end
pastebin()