Lua.is.the.best, on 07 June 2014 - 01:48 AM, said:
Now I can finally create an installer without creating a function called get(repo, file) and then calling it like a hundred times!!
Now, all I have to do is:
local username = "aepic999" local repo = "MyProject" function hte() if fs.exists(gitget) shell.run("gitget", username, repo) else print("GitGet application does not exist. Downloading...") shell.run("pastebin", "get", "6aMMzdwd", "gitget") shell.run("gitget", username, repo) end echo("Installed.") end if http then print("HTTP enabled. You can continue.") hte() else print("HTTP not enabled. App will not continue.") endwhile my other version that used get() was long, and I gave up when I reached the API folder.
EDIT: Put a measure in there to make sure it doesn't still run the code when HTTP API is off.
EDIT 2: Put the hte() function directly after the variables so the if wouldn't get confused, nor the function.
EDIT 3: And just to note, if you want to make this your own, change "username" and "repo", but KEEP THEM STRINGS! If you don't, the shell.run() calls I use will fail.
EDITSAURUS: You can hard-code the strings (hardcoded: not in variable or dependent on variables).
Well, it would be more user friendly if it looked more like:
local username = "aepic999" local repo = "MyProject" function hte() if fs.exists(gitget) then --You missed this shell.run("gitget", username, repo) else print("GitGet application does not exist. Downloading...") shell.run("pastebin", "get", "6aMMzdwd", "gitget") shell.run("gitget", username, repo) end if fs.exists("one of your files") then --You don't check if it was installed before saying it was installed print("Installed.") -- echo? else print("An error occured while attempting to install.") end end if http then print("HTTP enabled. You can continue.") hte() else print("HTTP not enabled. App will not continue.") end