Go Back   The Older Gamers Forums > TOG Strategy, RPG and Other Games > Minecraft (Public Forum)

Minecraft (Public Forum) Build it and they will come

Reply
 
LinkBack Thread Tools
Old 15th October 2013, 08:54 AM   #1 (permalink)
Ace - Post: 8329 TOG Silver Level Supporter
 DaedalusAlpha's Avatar

Default Having fun with ComputerCraft and Dropbox

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:

Code:
Dropbox
+-Public
  +-CCPrograms
    +-Project1
      +-index.txt
      +-startup
      +-settings
    +-Project2
    +-Project3
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.
__________________
EVE Online characters:
Daedalus II
ex-CEO TOGOA, Daedalus III slave of Daedalus II
GW2 characters:
Little Molok Asura Engineer


"Each day I don't get an attempt on my life by a robot from the future I see as a personal failure"

Last edited by DaedalusAlpha; 17th October 2013 at 07:42 PM.
DaedalusAlpha is offline   Reply With Quote

Old 15th October 2013, 02:44 PM   #2 (permalink)
Retired Captain
Retired Captain
Competent - Post: 444
 Gedarn's Avatar

Brooding
Default

Awesome work there Daedalus, no use to me as I haven't done any programming(or have the knowledge) since about 1982.
__________________
Minecraft - Scataboens
Mechwarrior Online - Angrah
Firefall - Gedarn
Star Citizen - Gedarn
Gedarn is offline   Reply With Quote
Old 15th October 2013, 06:23 PM   #3 (permalink)
Ace - Post: 8329 TOG Silver Level Supporter
 DaedalusAlpha's Avatar

Default

There is always time to jump back on the bike
__________________
EVE Online characters:
Daedalus II
ex-CEO TOGOA, Daedalus III slave of Daedalus II
GW2 characters:
Little Molok Asura Engineer


"Each day I don't get an attempt on my life by a robot from the future I see as a personal failure"
DaedalusAlpha is offline   Reply With Quote
Old 15th October 2013, 10:50 PM   #4 (permalink)
Deadly - Post: 1439
 dancastles's Avatar

Relaxed
Default

ummmmm, I didn't understand the bit after... " thought I should share..."

__________________

dancastles is offline   Reply With Quote
Old 17th October 2013, 09:48 AM   #5 (permalink)
Competent - Post: 307

Bored
Default

LOL, going to have to have a look at this on a day my brain is atleast partialy functioning to try and understand it. I'm a creature of habit, if its not a habit its hard to do.
__________________
Thanks
EK

Emeraldknight is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +11. The time now is 10:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0