I thought I should share a neat little program I've been using to control all my other programs.

Code:

local args = { ... }
if #args < 1 then
args[1] = os.getComputerLabel()
if args[1] == "" then
return
else
print("Using "..args[1].." as project name")
end
end
local index = http.get("https://dl.dropboxusercontent.com/u/?????????/CCPrograms/"..args[1].."/index.txt")
if not index then
print("Invalid project name, project does not exist on server")
return
end
local filename = index.readLine()
while filename do
if not (filename == "") then
print(filename)
local infile = http.get("https://dl.dropboxusercontent.com/u/?????????/CCPrograms/"..args[1].."/"..filename)
if infile then
local outfile = fs.open(filename, "w")
local line = infile.readLine()
while line do
outfile.writeLine(line)
line = infile.readLine()
end
outfile.close()
end
end
filename = index.readLine()
end
index.close()

(replace ??? with your own dropbox id)

What this program does is it transfers programs or "projects" that reside on your dropbox account to a CC Computer. This makes it extremely easy to code even on a server as you don't have to re-upload your programs with pastebin as soon as you make a change, instead you simply save the file and dropbox will make it available.

Usage

To make this work you create the following folder structure in your Dropbox "Public" folder:

In each project folder you have a file called index.txt, and in this file you list all the other files used by this particular project, say for example "startup" and "settings" as in Project1. They all have to be on a new line in index.txt, so in this case the contents of index.txt would look like:

Code:

startup
settings

Once this is done you are free to modify the files as much as you want, to sync it with your CC Computer simply run the command "update Project1" to sync Project1. One can also be clever in the naming of the projects and label the computers the same name, in that case all you have to write is "update" and the program will fetch the project with the same name as the computer label. (If the computer is labelled "mainframe" update will fetch the "mainframe" project from dropbox).

Naming the primary file "startup" is neat as it means you can simply update the file and restart the computer (or leave it until the chunk reloads) to always have the program running. (Most my programs tend to be of this type).

Other features

This program have other neat uses as well, if you for example have this project available:

Code:

+-CCPrograms
+-update
+-index.txt
+-update

then you can simply write "update update" in a CC Computer and the update program itself will update! Neat!

Finally you can have the update program as a part of another program to provide automatic updating. My mining turtle program for example has a function for remote updating, I simply send a specific control signal which will make it call the update program (which downloads the newest startup file for the mining turtle), and then reboots the turtle. As the turtle boots again, it will look for a startup file, find our new startup file and presto, the new version of the program starts

If you're interested in the program you can get it on a disk from me ingame. Or use my CC Paster program (mentioned in an older thread) to copy it once and then create your own disk to spread it. Or simply create a pastebin paste and use that.