←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Automatically download Pastebin programs

Barlender's Photo Barlender 09 Jul 2015

Ok, so I am trying to create a program which uses pastebin links to download other programs onto the computer. I've seen this method done with other programs, I just never actually saw the command to do so.

The command which I attempted to use was:

if fs.exists("<program name>") ~= then
shell.run("pastebin get <pastebin code> <program name>")
end

The error I got when I ran this program was "bios:339: [string "startup"]:1: unexpected symbol". I assume the unexpected symbol refers to the "~", but I am not sure. Any help would be much appreciated.

Quote

Square789's Photo Square789 09 Jul 2015

Very simple, you just compared the returned value with...nothing
The compiler expected the end of the statement with the brackets, but then you just put an operator there.
I'd use
if not fs.exists(filename) then
Also, don't use a string in the fs.exists()-function ("<program name>") but a variable.
Same with <pastebin code>, replace this with
shell.run("pastebin get "..pastecode.." "..filename)

Edited by Square789, 09 July 2015 - 02:27 PM.
Quote

meigrafd's Photo meigrafd 09 Jul 2015

Have a look on this: https://github.com/s...r/bootstrap.lua
Quote

KingofGamesYami's Photo KingofGamesYami 09 Jul 2015

View Postmeigrafd, on 09 July 2015 - 02:49 PM, said:


That really isn't relevant to the error in question. It's his file that's causing problems.
Quote

Barlender's Photo Barlender 10 Jul 2015

View PostSquare789, on 09 July 2015 - 02:24 PM, said:

Very simple, you just compared the returned value with...nothing
The compiler expected the end of the statement with the brackets, but then you just put an operator there.
I'd use
if not fs.exists(filename) then
Also, don't use a string in the fs.exists()-function ("<program name>") but a variable.
Same with <pastebin code>, replace this with
shell.run("pastebin get "..pastecode.." "..filename)

I tried your suggestion, and it worked! Also thank's for suggesting that I use a variable rather than a string, that was another issue I was having :P Thanks for the help
Quote