Posted 15 April 2013 - 01:07 PM
Terraform
turn your deserts into meadows, change dirt beaches to sand beaches, explore caves made of wood!
[media]http://youtu.be/h8jS1eF_als[/media]
What is it?
Terraform is a ComputerCraft Turtle program that digs out blocks and replaces them with the blocks YOU want, keeping the landscape's and caves shape while mining valuable resources at the same time.
Usage and parameters
terra [cycles] [dump] [quick [depth]]
All params are optional. They can be put in any in almost any order; almost, because 'quick' will interpret following it number as the depth to dig.
cycles - number. How many 'steps' infront of the turtle should be terraformed, i.e.: terra 15. If the number of steps is not given, the program will work in supervision mode, requiring conformation for each new cycle.
dump - literal string. Using this param will make the turtle throw up :)/> the inventory content (but not from the config slots) after each cycle.
quick - quick mode, by default it will dig just 5 blocks deep. Useful if you want to quickly replace the top layers and do mining by other means or not at all.
depth - number that comes after 'quick', lets you specify the depth of the quick mode, i.e.: terra 64 quick 3 will go for 64 cycles (or steps) replacing blocks to 3rd layer deep on it's path.
Configuration
Slot 1 - block used for the surface layer
Slot 2 - 'subsurface' block, placed on relative depth from 2 to 4, that's 3 layers.
Slot 3, 4 - 'filler' blocks, those will be used to replace everything else.
Default behavior
• Turtle won't start a terraform cycle unless the fuel level is at least 600. This was made on purpose so that turtle would not run out of fuel in the middle of a cycle deep in a hole (or a lava lake). I took this aproach because coming up with a proper and effective scheme for correct and constant fuel calculations was too mindbending.
• Turtle will try to make the best out of items in it's inventory. If it goes out of a particular block, it will try to restock it out of stuff it dug out.
• The program was written to operate without any supervision as much as possible. The only time the turtle will need your attention is when it goes into pitstop mode. It does that only when:
- fuel level drops below 600 after finishing a cycle
- it runs out of config blocks and cannot restock from internal inventory
- it's inventory is full.
• After a finished cycle the turtle will do one "step" forward, meaning it won't just move straight forward, but will position itself as close to the ground as possible, which means it will climb mountains and go down valleys, removing the need for manual height positioning. Be sure to remove tall grass, flowers, torches, redstones and other types of non-solid blocks, as they are percieved and mapped by the turtle as normal blocks. This can't be dealt with without block id recognition (and we know vanilla CC won't get this feature ever).
Why was it made? A piece of (possibly boring) history.
As I was traveling to find a good place for that, I stumbled upon some generator-glitched chunks with a desert and decided that this would be the perfect place. It was, however overun by monsters, including creepers that were blowing up my valueble sand resources and digging them by hand was a real chore. I started to wonder if I could somehow automate the digging process and at the same time strenghten the surface with cobble, so it won't get distroyed as much. That's when the Terraform idea was born and coding started.
V1 was designed to work with many turtles simultaneously thru rednet and remote control. As cool as it may sound, it was very primitive, depended on many external programs, needed lots of supervision, but in the end was doing the job. Later I grew accustomed to this place, which soon became my new home. I couldn't turn it to a wasteland anymore, still I really missed grassy fields… so I rewrote Terraform and introduced layers, also made some attemts to automatize it more so I could just leave it working while doing other tasks. That was V2.
At some point I realized that the whole remote/rednet concept is actually making turtles work slower as each turtle needed to wait for the others to finish it's job. That's when I started working on V3, and God bless it came to that, because as it turned out, V2 had some major bugs. It was only thanks to sheer luck that they somehow never revealed themselves.
V3 was a major rewrite. Previous concept was scrapped completly and the new design revolved around an autonomous turtle, automated as much as possible. All external program dependencies were removed and needed functionality was included in the program to make it standalone. Now whole rows of turtles may work beside each other individually not waiting for each other and not stopping each other. Pitstops don't have to take place on every finished cycle and the overall process is much faster. V3.5 also introduced the quick mode and inventory dump feature.
Future?
For my personal needs I find Terraform feature-complete. Of course there are still some potential areas where theoretically the program could be optimized in terms of speed and/or fuel effeciency. I was thinking about a few approaches, but in the end came to conclusion that the complexity of the code needed would require far more time than I can give it. Readability and maintenance would also suffer further as current code is already not-so-clean and a bit hackish in some places. Even tho I tried to stick to good practices, more than often LUA with its kinks is hard (for me) to work with. However some optimization concepts still return to me and crawl on my mind from time to time and I may try to implement them in unforseen future.
Inventory managment itself could also be improved quite a lot if turtles could access information about blocks such as IDs, names, damage values and so on. As we know, that won't happen in vanilla CC and I'm not willing to write special versions of Terraform for differently modded turtles.
Download
MediaFire
Pastebin
Copyright
Do what you want with it, just be sure to give me some credit if you use my code in your project.
turn your deserts into meadows, change dirt beaches to sand beaches, explore caves made of wood!
[media]http://youtu.be/h8jS1eF_als[/media]
What is it?
Terraform is a ComputerCraft Turtle program that digs out blocks and replaces them with the blocks YOU want, keeping the landscape's and caves shape while mining valuable resources at the same time.
Usage and parameters
terra [cycles] [dump] [quick [depth]]
All params are optional. They can be put in any in almost any order; almost, because 'quick' will interpret following it number as the depth to dig.
cycles - number. How many 'steps' infront of the turtle should be terraformed, i.e.: terra 15. If the number of steps is not given, the program will work in supervision mode, requiring conformation for each new cycle.
dump - literal string. Using this param will make the turtle throw up :)/> the inventory content (but not from the config slots) after each cycle.
quick - quick mode, by default it will dig just 5 blocks deep. Useful if you want to quickly replace the top layers and do mining by other means or not at all.
depth - number that comes after 'quick', lets you specify the depth of the quick mode, i.e.: terra 64 quick 3 will go for 64 cycles (or steps) replacing blocks to 3rd layer deep on it's path.
Configuration
Slot 1 - block used for the surface layer
Slot 2 - 'subsurface' block, placed on relative depth from 2 to 4, that's 3 layers.
Slot 3, 4 - 'filler' blocks, those will be used to replace everything else.
Default behavior
• Turtle won't start a terraform cycle unless the fuel level is at least 600. This was made on purpose so that turtle would not run out of fuel in the middle of a cycle deep in a hole (or a lava lake). I took this aproach because coming up with a proper and effective scheme for correct and constant fuel calculations was too mindbending.
• Turtle will try to make the best out of items in it's inventory. If it goes out of a particular block, it will try to restock it out of stuff it dug out.
• The program was written to operate without any supervision as much as possible. The only time the turtle will need your attention is when it goes into pitstop mode. It does that only when:
- fuel level drops below 600 after finishing a cycle
- it runs out of config blocks and cannot restock from internal inventory
- it's inventory is full.
• After a finished cycle the turtle will do one "step" forward, meaning it won't just move straight forward, but will position itself as close to the ground as possible, which means it will climb mountains and go down valleys, removing the need for manual height positioning. Be sure to remove tall grass, flowers, torches, redstones and other types of non-solid blocks, as they are percieved and mapped by the turtle as normal blocks. This can't be dealt with without block id recognition (and we know vanilla CC won't get this feature ever).
Why was it made? A piece of (possibly boring) history.
Spoiler
This program was born out of specific needs that suddenly manifested themselves about the same time. I was in great need of *lots* of cobble, sand, even gravel for a *big* project involving many large scale goals and objectives. I knew I'd need a few quarries for that, however I didn't want grow a wasteland near my living space.As I was traveling to find a good place for that, I stumbled upon some generator-glitched chunks with a desert and decided that this would be the perfect place. It was, however overun by monsters, including creepers that were blowing up my valueble sand resources and digging them by hand was a real chore. I started to wonder if I could somehow automate the digging process and at the same time strenghten the surface with cobble, so it won't get distroyed as much. That's when the Terraform idea was born and coding started.
V1 was designed to work with many turtles simultaneously thru rednet and remote control. As cool as it may sound, it was very primitive, depended on many external programs, needed lots of supervision, but in the end was doing the job. Later I grew accustomed to this place, which soon became my new home. I couldn't turn it to a wasteland anymore, still I really missed grassy fields… so I rewrote Terraform and introduced layers, also made some attemts to automatize it more so I could just leave it working while doing other tasks. That was V2.
At some point I realized that the whole remote/rednet concept is actually making turtles work slower as each turtle needed to wait for the others to finish it's job. That's when I started working on V3, and God bless it came to that, because as it turned out, V2 had some major bugs. It was only thanks to sheer luck that they somehow never revealed themselves.
V3 was a major rewrite. Previous concept was scrapped completly and the new design revolved around an autonomous turtle, automated as much as possible. All external program dependencies were removed and needed functionality was included in the program to make it standalone. Now whole rows of turtles may work beside each other individually not waiting for each other and not stopping each other. Pitstops don't have to take place on every finished cycle and the overall process is much faster. V3.5 also introduced the quick mode and inventory dump feature.
Future?
Spoiler
Terraform has been thoroughly tested. Every found bug has been dealt with. At this time it doesn't contain any major bugs, neither any small ones that I know of.For my personal needs I find Terraform feature-complete. Of course there are still some potential areas where theoretically the program could be optimized in terms of speed and/or fuel effeciency. I was thinking about a few approaches, but in the end came to conclusion that the complexity of the code needed would require far more time than I can give it. Readability and maintenance would also suffer further as current code is already not-so-clean and a bit hackish in some places. Even tho I tried to stick to good practices, more than often LUA with its kinks is hard (for me) to work with. However some optimization concepts still return to me and crawl on my mind from time to time and I may try to implement them in unforseen future.
Inventory managment itself could also be improved quite a lot if turtles could access information about blocks such as IDs, names, damage values and so on. As we know, that won't happen in vanilla CC and I'm not willing to write special versions of Terraform for differently modded turtles.
Download
MediaFire
Pastebin
Copyright
Do what you want with it, just be sure to give me some credit if you use my code in your project.