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

Pastebin help

Started by Awsomehawk, 03 October 2012 - 07:49 AM
Awsomehawk #1
Posted 03 October 2012 - 09:49 AM
Im trying to write a program on a floppy disk that will automatically download programs from pastebin how would i do so or is it even possible
Luanub #2
Posted 03 October 2012 - 10:26 AM
Yeah you just need to do the following

Pastebin(pastebinID,"fileName")

So

Pastebin(EwL1C0qw,"disk/startup")

Would create the startup file on a disk using the code at http://www.pastebin.com/EwL1C0qw.
Awsomehawk #3
Posted 03 October 2012 - 11:24 AM
ok but what if i want the disk to run pastebin and put it on the computer so i can have a floppy disk that when i enter it into a computer it will download the programs i told the disk to download
Luanub #4
Posted 03 October 2012 - 11:57 AM
The same way, just change the path.

Pastebin(EwL1C0qw,"startup")

If you're doing multiples you can use some tables and a loop to make it a little easier.

local tCodes = {"code1", "code2", "code3"} --replace with actual codes
local tFiles = {"file1","file2","file3"}  --and replace these will the names you want the files to have

for x=1, #tFiles do
  Pastebin(tCodes[x],tFiles[x])
end
Cloudy #5
Posted 03 October 2012 - 12:04 PM
What. Pastebin isn't a function.

shell.run("pastebin", "code", "location")
Luanub #6
Posted 03 October 2012 - 12:12 PM
What. Pastebin isn't a function.

shell.run("pastebin", "code", "location")

lol sorry I forgot to put the function I use in. It's been a while since I've played with pastebin.


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
Awsomehawk #7
Posted 03 October 2012 - 04:45 PM
Thank you so much
Now I can launch my project