Seeing as we're sunsetting our FTB server for now, I figured I'd post the collection of turtle programs I'd build over time, as well as my own private program server code. These are all free for you to take, modify, and use however you want (Just try to give a throwback if you distribute them yourself).

1. Crafty - This was my first module, and it's already up in this thread: http://www.computerc...__fromsearch__1

2. Enderage - This module completely abstracts using ender storage for building materials, and can be found here: http://pastebin.com/L9canaZa.

This is an extremely simple module to use, as detailed by this code:

dofile("/Enderage.lua")
bricks = Enderage:new(1, 15)
bricks:place()  // or bricks.palce(bricks), if called from another object.

This tells enderage that I want bricks in slot 1, and the ender chest filled with bricks is in slot 15. By using the Enderage:place() methods (instead of turtle.place()), it allows Enderage to keep track of how many items are left, and refill all by itself from the ender chest. This module is extremely handy, and is used in two of my other modules.

3. Gassy - This module has the same feel as the Enderage module, but instead it's used from tracking movement and fuel. http://pastebin.com/f3Zp3ydM

Gassy is initialized like so:

dofile("/Gassy.lua")
Gassy.init(16)

The number is the location of the ender chest filled with fuel, and gassy uses Enderage under the covers (make sure Enderage.lua is present) to refuel. Gassy has plenty of wrapper functions that should be used instead of the turtle.move sets, if you do Gassy will refuel whenever it gets low!


Gassy.up()
Gassy.down()
Gassy.forward()
// All 3 of the above functions can also take an integer parameter, and will be repeated that many times.
// Ex: Gassy.up(4) will go up 4 spaces.

Gassy.turnLeft()
Gassy.turnRight()
Gassy.turn(0)

The last line of code brings us to what makes Gassy awesome, it can track your movement for you. When Gassy.init() is called, it not only sets up fuel tracking, but it also sets the position to (0, 0, 0) and the direction to 0. Gassy.turn can then be used to turn an arbitrary direction, in relation to where it started. However many times you've turned, Gassy.turn(0) will have you facing the direction you started in. Other options are 1: left, 2: back, and 3: right, all in relation to start position.

The other cool thing about Gassy is waypoints. Here are some function examples:

Gassy.go(5, 2, -1)
Gassy.go_point()
Gassy.push()
Gassy.pop()
Gassy.home()

Gassy.go will go to the specified coordinates (x, y, z) in relation to the last waypoint, or where it started if none exist. It's not very smart, and it just resolves delta x, delta y, and delta z in that order, but that usually works for construction. Gassy.go_point will go to the location and facing of the last waypoint. Gassy.push pushes the current location and facing on the waypoint stack, and resets all values to 0. Gassy.pop removes a waypoint from the stack, and adds those values to the current values. Gassy.home is a shortcut to pop the whole stack and go_point.

4. Panic - Ever wished you could present an error when something went wrong, but be able to continue the program once you've rectified it? I did, which is exactly what Panic does. Its extremely simple, only one function call. http://pastebin.com/VS0bDTCj


dofile("/Panic.lua")
Panic.panic("All the base are belong to us!")

This will pause and present the error, and allow you to kill the program or continue execution. This is used by the Gassy program, in case you run into things, and the Enderage program, in case there's a problem.

5. Cons - This module contains mostly personal building code, but there are some functions that can be really handy for automatic construction (That's what most of these modules are really here to accomplish). http://pastebin.com/vHfZFLMA


Cons.eLine(5, brick)
Cons.eFloor(6, 7, brick)
Cons.eRectangle(4, 4, brick)
Cons.eBlueprint({
			{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2 },
			{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }
		  }, glass, bricks)

The all functions are implemented with Enderage:placeDown(). The line, floor, and rectangle all work as expected, taking a length and/or width and an Enderage object that has been initialized. They make a line, a floor (filled in rectangle), and a rectangle (just the outside). Cons.eBlueprint is probably my favorite by far, as it allows you to build complex patterns that are easy to verify in code, without tons and tons of helper code. It takes a "blueprint", which just an array filled with other arrays, which represent the rows of the layer. The turtle will go along each row and column, and put the specified block in the correct place. The numbers represent which argument to use as the block for that space, with 0 always being nothing. In this example, 1 corresponds to glass, and 2 corresponds to brick.

6. Bluenet - USE AT YOUR OWN RISK. This is a module I made for a project that was never finished, so I can't guarantee everything in it works as expected. I don't know of any bugs, just keep in mind that it was a WIP. This is a collection of common networking functions to implement safer Rednet communication. It's very possible there's a library out there that does the exact same thing with more reliability, so do your research before using this. http://pastebin.com/iYsa57p7

7. Private code hosting - I wanted to highlight how I was able to develop the code above, and get it to my turtles on our server. If you have access to a web server, this is a much better way of doing things than using pastebin. First of all, you'll need this script (get): http://pastebin.com/H8gFbHeL. You'll also need this one if you plan on using projects: http://pastebin.com/rxQyPDjm (name it split.lua).

Theses allow you to connect to your private server (make sure you set the hostname in the get script, i removed my own for obvious reasons) and download lua files to a turtle.

get file foo
get file foo.lua
If .lua is left off the end, it searches for foo.lua but names it foo when it is downloaded. if .lua is added, it still finds the same file but keeps .lua.

Projects allow you to download multiple files with one get command. This is useful if you have a project that requires certain libraries to be present (like the ones above). A project file consists of a name (MyProject) and a project extension .proj, ex. MyProject.proj. Here's what one might look like:

Gassy.lua
Enderage.lua
Cons.lua
Panic.lua
construct

Each line is interpereted as a "get file" call. The project is downloaded with "Get proj MyProject".

Server setup: The web server now needs to be set up to serve files to your turtle. This can be accomplished with a simple php script, named paste.php:

<?php
	if(isset($_GET['f'])) {

		if(file_exists("src/" . $_GET['f']. ".lua"))  {
			echo file_get_contents("src/" . $_GET['f']. ".lua");
		} else if(file_exists("src/" . $_GET['f'])) {
			echo file_get_contents("src/" . $_GET['f']);
		}

	} else if(isset($_GET['p'])) {

		if(file_exists("src/" . $_GET['p']. ".proj"))  {
			echo file_get_contents("src/" . $_GET['p']. ".proj");
		}

	}
?>
Just put all your programs in src/ (or symlink to your source directory), and you're good to go!

Thanks for reading, even if it was just part. I know it was a long post, but I wanted to make sure everyone could get and use these modules, they saved me a lot of time (once they were written of course :P/>)
Let me know if you have any questions/comments/bugs, and I'll try to check back on the thread every now and again!