Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Roachy

Overhauled dig.lua script

Recommended Posts

So yall are some crazy people... making APIs, full OSes and compilers, etc. I'm just a ComputerCraft noob who likes controlling turtles and robots to do my dirty work. When I came over from ComputerCraft I was a bit surprised at the lack of excavation programs for robots.

So, starting with the default OC dig.lua program, I overhauled it to be more robust, reliable, and flexible, and to mimic what I used to use for my Turtles. There's still a lot of cool features I'd like to add but in my experience it is infinitely more reliable now. The major changes and plans are below.

Because I'm devoid of imagination I named it dig2.lua. It can be found on GitHub here. Usage and a diagram of how it functions can be found in the file.

Changes from original dig.lua
	- Now accepts 3 arguments by default for <depth (forward/back)>, <width (left to right)>, and <height (y axis)>
        Previously it accepted one argument for depth/width and dug as far down as it could
        -S option for original "Square" behavior, with one dimension given
        -C option for perfect cube, with one dimension given
	- New -j option allows you to skip down to any layer in the intended excavation
        Useful for when the excavation fails for whatever reason
        So you can reposition the robot at the start and have it skip all the layers already excavated
	- Added energy monitoring
  		Robot will calculate a reasonable energy reserve based on the size of the excavation and return to origin point when approaching that reserve
	- Overhauled logic, functionized and optimized code reuse and readability, and added reasonable commenting debug console output
	- Overhauled failure logic flow
	    Robot will return to origin point after fully failing out of the logic layers
        With the debug output this allows for much easier identifications of what's going wrong with your dig

Plans for the future if I get around to them
	- Add option to discard cobble/stone
	- Add failure recovery techniques (e.g. can't hover high enough so move to wall)
	- Add ability to specify where on the outskirts of the dig the chest and/or charger station are located
	- Re-implement logic to continue next layer without returning to origin corner (temporarily removed for simplicity)
	- Add/overhaul argument parsing logic
	- Add ability to refuel via generator upgrade if present
	- Add more compatibility checks for various components and upgrades
	- Improve usage message formatting or font size to better fit screen
      
Known isssues
      - On deep digs robot gets stuck climbing up to return home without the tier2 hover upgrade
      		Could easily be resolved for most cases by making him return to a wall/corner BEFORE moving up
      		The "up-first then side" behavior also causes annoying swiss cheese effect in digs where you skip a bunch of unexcavated layers
      - Script was designed for using Tinker's Construct tools with nearly infinite-durability/mending
      		There's no real logic to deal with loss of tools, but the failure code should cause robot to return home once it can no longer dig

 

Cheers,

== Roachy

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.