This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
hego555's profile picture

Install Scripts?

Started by hego555, 04 October 2012 - 05:28 AM
hego555 #1
Posted 04 October 2012 - 07:28 AM
How do you make install scripts??

I know you upload to pastebin, but I dont understand what you do from there!

Cranium made a install script on my server but I never understood, so if someone can explain!
jag #2
Posted 04 October 2012 - 10:52 AM
You could do
pastebin get pastebinID newProgramName
Mtdj2 #3
Posted 04 October 2012 - 11:15 AM
Jag, I think hego means something like this:
hego,as I heard him said:
I wanna make an installer for my extremly awesome OS, but I don't know how to paste the code to my files. What should I do?
Well, I have an answer to that. Do something like this:

rs = http.get("http://www.google.com/) --This line downloads the file
lulz = rs.readAll() --Reads the contents
lol = fs.open("startup","w") --Opens file
lol.write(lulz) --writing the file
lol.close()
Hope i helped.
PS: i will edit with more info.
Luanub #4
Posted 04 October 2012 - 01:23 PM

rs = http.get("http://www.google.com/) --This line downloads the file

This is not a good thing to do especially since you did not make it a local. It will overwrite the rs api. So if you do:

rs.setBundledOutput("back", colors.white)
Or something a long those lines it would try to run:

http.get("http://www.google.com/).setBundledOutput("back", colors.white)
And error…

To the OP:

Its real simple. You can either use a function or use shell.run() to run the pastebin program and download the code. Here is an example with a function:

function Pastebin( sCode, sPath )
local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ))
if response then
    local sResponse = response.readAll()
    response.close()
    local file = fs.open( sPath, "w" )
    file.write( sResponse )
    file.close()
end
end

if not fs.exists("filename") then
  Pastebin("pasteBinCode","filename")
end

Even easier use shell.run() although personally I prefer the function:

if not fs.exists("filname") then
  shell.run("pastebin","get","pasteBinCode","filename")
end

You can add a menu to it, uninstall options, update options, etc…