Posted 11 June 2014 - 01:01 AM
Alrighty, I'm working on kind of a basic API to give myself some essentials I end up using a lot, and my pastebin update is throwing nil (line 71), would you happen to know what is up?
For some reason the:
shell.run("pastebin", "get", pastebinExtension, programPath.."temp")
line gets errored out, and even if I manually replace all variables with their actual name and remove the 'temp' addition, I get the same error. Any idea what is going on or why?
Spoiler
--[[
CoreAPI is designed to provide some of the regularly needed
features of general types of programs in one place.
It is a mish-mash of functions where I wasn't sure where to place
elsewhere.
]]
version = "0.0.1"
--==Startup Functions==--
--Test This
function setStartup(...)
--Takes any number of arguments and creates
--a startup script to execute the program (argument 1)
--with any following parameters (arguments afterwards)
local args = {...}
--Making sure I don't break a previous startup
if fs.exists("startup") then
fs.move("startup", "oldStartup")
end
--Saving the params file
if not fs.exists("tempFiles/") then
fs.makeDir("tempFiles")
end
local tempStartupParams = fs.open("tempFiles/tempStartupParams", "w")
tempStartupParams.write(textutils.serialize(args))
tempStartupParams.close()
--Generating the startup file
local startupFile = fs.open("startup", "w")
startupFile.writeLine("--If you can read this, remove it")
startupFile.writeLine("local params = fs.open(\"tempFiles/tempStartupParams\", \"r\")")
startupFile.writeLine("local args = textutils.unserialize(params.readAll())")
startupFile.writeLine("params.close()")
startupFile.writeLine("shell.run(unpack(args))")
startupFile.close()
end
function removeStartup()
--Removes the startup you created and sets old one
--(if it exists), back to normal place
--Removes set startup and puts new one back
if fs.exists("oldStartup") then
if fs.exists("startup") then
fs.delete("startup")
end
fs.move("oldStartup", "startup")
end
--Gets rid of the tempFiles Folder
if fs.exists("tempFiles") then
fs.delete("tempFiles")
end
end
--==Update Functions==--
function checkUpdate(pastebinExtension, programPath)
--Downloads the latest version of the program and compares size.
--If size is different, it deletes the old and replaces with the new
--Returns true if there was an update.
print("Checking for updates...")
shell.run("pastebin", "get", pastebinExtension, programPath.."temp")
if fs.exists(programPath) then
if fs.getSize(programPath) == fs.getSize(programPath.."temp") then
fs.delete(programPath.."temp")
print("You are up to date.")
return false
else
print("Updates found. Applying...")
fs.delete(programPath)
fs.move(programPath.."temp", programPath)
print("Done!")
return true
end
else
print("Updates found. Applying...")
fs.move(programPath.."temp", programPath)
print("Done!")
return true
end
end
function updateApis()
--Updates/Downloads newest renditions of
--my APIs (including this one)
checkUpdate("kvLnweEf", "api/core")
checkUpdate("9QFxP4Ff", "api/move")
checkUpdate("E4cPHATD", "api/network")
end
For some reason the:
shell.run("pastebin", "get", pastebinExtension, programPath.."temp")
line gets errored out, and even if I manually replace all variables with their actual name and remove the 'temp' addition, I get the same error. Any idea what is going on or why?
Edited on 10 June 2014 - 11:02 PM