it's my first tutorial so...
Step One
You shall be needing a GitHub repository - head to www.github.com and create an account.
Then you should create a new repository.
The name can be anything, Tungsten OS or such anything!
And the description is optional.
You don't need the .gitignore and license features yet since you haven't really made Tungsten OS proper yet. It is still under development.
Step Two
With a GitHub repository located at www.github.com/youname/theRepositoryName you can continue on here.
Now I have a nifty little program called (not mine) SourceTree which you can get here.
Setting up SourceTree
The Installer
Note: You need the HTTP API enabled for this to work!
How to enable the HTTP API
Now, the file we shall be downloading is called 'startup', located at www.github.com/myName/repo/startup .
If you try to download that into ComputerCraft it'll show you all of the HTML details, which is useless - so we need the raw file which is found at
https://raw.github.com/me/repo/startup .
That is what we shall download.
So now to get, read and save 'startup' off GitHub, we shall use the code:
local download = http.get("https://raw.github.com/myName/repo/startup") --This will make 'download' hold the contents of the file. local handle = download.readAll() --Reads everything in download download.close() --remember to close download! local file = fs.open("startup","w") --opens the file 'startup' with the permissions to write. file.write(handle) --writes all the stuff in handle to the file 'startup'. file.close() --remember to close download!That is basically it!
Now putting that code in for each file is a mission, so you can put it into a local function: (in the installer)
This code will make sure it downloaded it, else if it didn't the installer will return false with an error message.
local function get(repoFile,saveTo) local download = http.get("https://raw.github.com/myName/repo/repoFile") --This will make 'download' hold the contents of the file. if download then --checks if download returned true or false local handle = download.readAll() --Reads everything in download download.close() --remember to close the download! local file = fs.open(saveTo,"w") --opens the file defined in 'saveTo' with the permissions to write. file.write(handle) --writes all the stuff in handle to the file defined in 'saveTo' file.close() --remember to close the file! else --if returned false print("Unable to download the file "..repoFile) print("Make sure you have the HTTP API enabled or") print("an internet connection!") end --end the if end --close the functionNow call this function with:
get("startup","startup") --remember the quotation marks! (" ")
That is basically it for an advanced installer of GitHub. That is exactly what the pastebin get program does, it just doesn't run with a function and has the URL www.pastebin.com/raw?i= (or whatever)
and saves the raw.
If you need any questions just ask me. ALSO if the code I posted errors just tell me - I posted it without testing...
Edited by mrdawgza, 07 July 2014 - 10:19 AM.