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

Title:Tank Building Turtle

Started by surferpup, 09 January 2014 - 01:16 AM
surferpup #1
Posted 09 January 2014 - 02:16 AM
Build-a-Tank Turtle v. 2.0

I recently began programming in Lua and I have greatly enjoyed the language. Since this is my first post, I am still getting used to the forum interface. I haven't yet figured out how to include screenshots, so please forgive the lack of graphics.

For an initial post, I am offering my Build-a-Tank Turtle, which builds any legal size steel or iron tank. I programmed it in part to work on creating a program with a decent user interface. The use of it should be fairly simple. Simply download the program and save it as the startup program for your turtle. When the turtle starts, it should run the program.

In order to build a tank, first add fuel to slots 13-16 in the turtle and select the refuel option. You can use the move option from the menu to move the turtle to its starting location. The turtle will build the first location at its current location (the first block will occupy the same location as the turtle is presently at). From there, the turtle will build the tank forward and to the left.

The menu is as follows:
  1. Help – display help
  2. Set Tank Size – allows only legal tank sizes
  3. Move Turtle – manually reposition turtle to user selected starting location (requires fuel)
  4. Refuel – will scan slots and consume all fuel
  5. Start Building – turtle will build selected size tank if materials and fuel present
  6. Quit & Power Off – quits the program and shuts down turtle
[namedspoiler='Screenshots"]
[center][b][size=5]Main Menu[/size][/b][/center]

[center][img]http://i1329.photobucket.com/albums/w556/simpk001/TankMainMenu_zps3ea472c2.png[/img][/center]

[center][b][size=5]Help Display[/size][/b][/center]

[center][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/TankHelp_zps5d5cae8c.png[/img][/center]



[center][size=5][b]Select Size[/b][/size][/center]

[center][size=5][b][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/SelectSize_zps38a71563.png[/img][/b][/size][/center]

[center][b][size=5]Move Function[/size][/b][/center]

[center][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/MoveFunction_zps609aa8b1.png[/img][/center]

[center][size=5][b]Refueling[/b][/size][/center]

[center][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/Refueling_zps85b936ab.png[/img][/center]


[center][size=5][b]Building Screen[/b][/size][/center]


[center][b][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/BuildingScreen_zpsb0b0e45e.png[/img][/b][/center]

[center][b][size=5]"Tanky" in Action[/size][/b][/center]

[center][img]http://i1329.photobucket.com/albums/w556/simpk001/minecraft/BuildingaTank_zps259d1616.png[/img][/center]

[center][/namedspoiler][/center]

Materials for the tank need to be loaded into the slots as follows:[list]
[*]Tank Walls need to go in slots 1-4
[*]Tank Guages need to go in slots 5-8
[*]Tank Valves need to go in slots 9-12
[*]Fuel (wood, coal, coke, etc) need to be placed in slots 13-16
[/list]
The NEED/HAVE lines of the interface will specify how many blocks of each kind are required as well as how much fuel is required to build the user-specified tank size. As the turtle builds the tank, a screen will show progress and report material/fuel usage.

The code is located on my pastebin account at [url="http://pastebin.com/XhnfgNqq"]http://pastebin.com/XhnfgNqq[/url]

To Do's include the following:
Spoiler
  • Include code to recover when required material is not present after initially starting build. This scenario arises if the user removes inventory from the turtle during the build.
  • Add feature to recover from server restarts or block unloads/loads. This is more of a wish than a to-do
Hope you enjoy this rather single-purpose turtle.
Edited on 31 January 2014 - 09:31 PM
Lyqyd #2
Posted 09 January 2014 - 10:17 AM
Moved to Turtle Programs.