r/ComputerCraft • • Jul 30 '20

Can anyone help me?

Ok so i have been looking on the internet for 2 hours now and i can not find how to get a file onto a cc computer.
Can anyone please help its driving me crazy.

1 Upvotes

11 comments sorted by

3

u/soboness5 Jul 30 '20

I am assuming you have code on your computer you want to push into the game?

I prefer PasteBin: https://www.computercraft.info/wiki/Pastebin_(program)

If you are running the MC server on your machine, I believe you can also find the CC folder and manually drop a file into the directory which will make it available in the game...but I can't remember exactly.

Hope that helps.

1

u/joch2em Jul 30 '20

hi thanks for the response sorry i wasnt clear but what i meant was that i need a nbs to go on the cc computer. The cc computer is on a server that i cannot acces the files of.
I also dont know how to get a nbs file or any file on paste bin.

2

u/soboness5 Jul 30 '20

NP - pastebin is great for text code transfer, but I don't think it works with files.

I also found this: http://www.computercraft.info/forums2/index.php?/topic/11809-lua-downloading-files-with-http/

Your server will need to have 'HTTP' turned on for CC. If it is, something like this might work if you can host the file somewhere for download.

function download(url, file)
local content = http.get(url).readAll()
if not content then
        error("Could not connect to website")
end
  f = fs.open(file, "w")
  f.write(content)
  f.close()
end

2

u/joch2em Jul 30 '20

function download(url, file)

local content = http.get(url).readAll()

if not content then

        error("Could not connect to website")

end

  f = fs.open(file, "w")

  f.write(content)

  f.close()

end

ok so it gives an error (yes i did replace the url and file with the url and file)

bios.lua:26: [string ".temp"]:1: ')' expected

edit: http is turned on

2

u/fatboychummy Jul 31 '20

that means you're missing a closing parenthesis somewhere. Likely on line 1.

I'm assuming you didn't directly copy that program here though as I cannot see an error on line 1 here.

1

u/joch2em Jul 31 '20 edited Jul 31 '20

hi i checked it again but it looks like i didnt make a mistakehere is what i put in the computer

function download(rickroll.rf.gd, megalovania.nbs)

local content = http.get(rickroll.rf.gd).readAll()

if not content then

error("Could not connect to website")

end

f = fs.open(megalovania.nbs, "w")

f.write(content)

f.close()

end

rickroll.rf.gd is the website

edit: ITS FIXED thanks for the help mate :D

1

u/joch2em Jul 30 '20

Thanks ill try it now :)

1

u/ePaint Jul 31 '20

Use pastebin get <pastebin code here> <name of the new file imported here>

The last post I have on my profile is a video where I use this method.

0

u/[deleted] Jul 30 '20

[deleted]

2

u/joch2em Jul 30 '20

its an nbs file and its on a server of wich i cannot acces the files.

2

u/minermenace Jul 31 '20

The use the first option

1

u/joch2em Jul 31 '20

omg thank you so fricking much