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

My developing environment

Started by THUNDERGROOVE, 26 March 2013 - 08:33 AM
THUNDERGROOVE #1
Posted 26 March 2013 - 09:33 AM
Hello,

As many of you might know, developing programs on a server is a complete pain with the continuous editing of your Pastebins. I've found a pretty fair workaround that allows me to edit my programs in my favorite editor and have them automatically sync to my Computercraft computers and turtles.

Dropbox, a service that allows you to upload files to the "cloud" is a free service that comes with a desktop client that allows for automagic syncing of folders to your Dropbox account. You can create and edit files in the synced folders and have them uploaded almost instantaneously. I've written a few functions that can help you achieve a similar setup.

Spoiler

local baseLink = "http://dl.dropbox.com/u/<Your Dropbox public folder>/"
function updateScript(n)
  local response = http.get(baseLink..n)
  if response then
	print("Huzzaaa we got the script")
  else
	print("You broke it.... shutting down")
	error()
end
local script = response.readAll()
response.close()
local file = fs.open(n, "w")

file.write(script)
file.close()
print("script updated")
end

Using this, one can make a universal updater similarly to what I have done here http://pastebin.com/0DJP0AaL
Also you'll have to replace baseLink with the link to your personal Dropbox folder
This assumes that there is a script name "scripts" in your Dropbox folder with three lists like
Spoiler

-- Name of script in folder
s = {
"flaxfarmer",
"Exit"
}
-- Menu entry name
n = {
"Flax Farmer",
"Exit Updater"
}
-- Description
d = {
"Heh, it farms flax. DUH",
"Exit the updater"
}

Although all the code is pretty rough and I understand it can all be optimized or prettied up this is merely just an example to show you how easy this can be to setup

Anyways happy coding and if you want to try this and don't have a Dropbox account yet feel free to use my referral code http://db.tt/LzMYARpz it can help me get some more space:)
oeed #2
Posted 26 March 2013 - 10:03 AM
I don't quite get the point of this. Couldn't you just use:

pastebin put ...
If I have got the wrong idea then what is this used for?
THUNDERGROOVE #3
Posted 26 March 2013 - 10:06 AM
Because with this you can have scripts auto update themselves on startup. When you use pastebin you have to copy your code, edit your pastebin(or make a new one) and then do

pastebin get <code> <name>
I like to just save the file in my editor and be able to run it right away

EDIT: Ohhh I see, this is for updating scripts from your real computer to your Computercraft computers
Zoinky #4
Posted 27 March 2013 - 09:09 PM
Nice work! +1
theoriginalbit #5
Posted 27 March 2013 - 09:22 PM
Instead of having some functions upload to dropbox, just use a Symlink (Windows) or Alias (OS X) or whatever it is on Linux. Have the files in dropbox, then use these Symlinks/Aliases to get the files off dropbox onto the computers and your dev env. update your development environment, dropbox updates immediately, the files on the computers update immediately.
airtonix #6
Posted 28 March 2013 - 08:51 PM
Instead of having some functions upload to dropbox, just use a Symlink (Windows) or Alias (OS X) or whatever it is on Linux. Have the files in dropbox, then use these Symlinks/Aliases to get the files off dropbox onto the computers and your dev env. update your development environment, dropbox updates immediately, the files on the computers update immediately.

Actually, they're called Junctions on Windows. On Linux and MacOsx they're called Symlinks (MacOSx is just BSD but apple likes to use the term alias). An alias in Linux and BSD is something different.
theoriginalbit #7
Posted 28 March 2013 - 08:54 PM
Instead of having some functions upload to dropbox, just use a Symlink (Windows) or Alias (OS X) or whatever it is on Linux. Have the files in dropbox, then use these Symlinks/Aliases to get the files off dropbox onto the computers and your dev env. update your development environment, dropbox updates immediately, the files on the computers update immediately.

Actually, they're called Junctions on Windows. On Linux and MacOsx they're called Symlinks (MacOSx is just BSD but apple likes to use the term alias). An alias in Linux and BSD is something different.
Probably more suited to say on Unix called Symlinks. but I get what you are saying, I was just meaning "Symbolic Links" which no matter OS you go on, you can call them that, since thats what they are :P/>