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

The water Ferret - Ocean exploration made easy

Started by Ion Silverbolt, 23 May 2014 - 04:35 AM
Ion Silverbolt #1
Posted 23 May 2014 - 06:35 AM
The Water Ferret - by Paul Olinger


Ever been deep under the ocean and wish there was an easier way to go up and back down? Is your nearest stronghold buried deep under the ocean? Or maybe you just want to have a deep underwater secret base?

Introducing the water ferret program. This program will go down to the deep ocean depths and build an access pipe straight up for you. Ideal for trying to reach underground mine shafts, strongholds, or other hard to reach places deep under the ocean. As an added bonus, it also works on land, and even in lava.

The program starts out by plummeting down until it detects a block which determines where the bottom of the ocean floor is. From there, the turtle pierces the ground and builds underground. This is so you can mine straight off your new tunnel without hitting water.

Just running the program without arguments works fine, but there are some commands that help improve the building process…


ARGUMENTS:
Spoiler[goto] [x] [y]
The goto argument tells your turtle where to go to potentially start drilling. Placing a turtle down in the middle of the ocean
isn't that easy unless you have a lilly pad, or some other way of getting a block there to place the turtle down. This argument
exists so you can tell your turtle where to move to.

If you use the goto argument, the next two arguments MUST be numeric values for the coordinates. The turtle's starting location
is considered x: 0 y: 0, so you determine where you want to move from there.

Example: waterFerret goto 140 -15
This will move the turtle forward 140 places, then left 15 places. If you use the goto argument, the next two arguments must be
numeric values for the x and y locations. If you don't wish to move x or y, then enter a value of zero for that coordinate.



[force]
The force argument tells the turtle to immediately start tunneling after it reaches the entered goto x and y coordinates.

Example: waterFerret goto 10 5 force
This will move the turtle forward 10 places, then right 5 places, then it will start tunneling.



[dock]
The dock option will append a small area next to the access pipe where you can dock your boat. Nothing fancy, but enough to keep
your boat from drifting away.

Example: waterFerret dock



[pierce] [z]
Using the pierce argument allows you to change the penetration depth. The default value is 6. A value of zero would build it right
at the ocean floor surface. The argument after pierce, which IS required, determines your depth. A negative value here also works, which will build above the ocean surface somewhere. Not sure how that might be useful, but it works. Setting a high value for pierce depth is useful if you're wanting to use this program for land penetration.

Example: waterFerret dock pierce 10
This would build a dock, then burrow down under the ocean floor 10 blocks.


SLOT PLACEMENT:
SpoilerSlots 1 - 13 are for structure blocks.
Slot 14 is reserved for torches.
Slot 15 and 16 are for ladders.


PROGRAM HIGHLIGHTS:
SpoilerI have implemented a lot of failsafes for the program so that the turtle does not stall at the bottom of an abyss somewhere. Whenever
the turtle needs something, it will make it's way to the surface.

The turtle will come to the surface to be refueled, or to get new blocks if it happens to run out. Once refueled or restocked, the
turtle will resume building.

This program handles obstacles fine, including sand, mobs, etc. If the turtle happens to hit bedrock, it will return home and abort
the mission. This will happen early on, as the turtle starts from the bottom up.


PITFALLS:
SpoilerDo not leave any block slot empty. Doing so, the turtle may pick up rubble from the ocean floor and then start using that for building.

This program does not do item checking for torches and ladders. I will probably add this soon, as it's fairly trivial to add, but for
now, make sure the turtle has enough. Even so, this isn't a huge deal, as the pipe is pretty much done by the time the program gets
this far.

Bedrock if you happen to hit it. If the turtle hits bedrock, it will return to the surface and shut down. This will happen early
in the program if you're going to hit bedrock.


SCREENSHOT:




Here is the pastebin: http://pastebin.com/qLtLKNJV


Happy tunneling!
civilwargeeky #2
Posted 26 May 2014 - 06:12 AM
Hi! I just tested out your program, and its pretty cool. I really like how it makes such a lavish entrance to the bottom, complete with torches and ladders :)/> I also like how it takes all the water out :)/> This will awesome for manually getting abyssal stone and things like that.

Now, just two things
First, I didn't see the spoiler where it says what slots to put things in :P/>, so if you could add in inventory checking, that would be great.
SpoilerIf you want, I'm working on inventory management in my quarry program, and you can use some code if you want:
function getRep(which, list) --Gets a representative slot of a type. Expectation is a sequential table of types [code]
  for a,b in pairs(list) do
	if b == which then return a end
  end
  return false
end
function getTableOfType(which, list) --Returns a table of all the slots of which type
  local toRet = {}
  for a, b in pairs(list) do
	if b == which then
	  table.insert(toRet, a)
	end
  end
  return toRet
end
function assignTypes(types, count) --The parameters allow a preexisting table to be used, like a table from the origianl compareitems...
  types, count = types or {1}, count or 1 --Table of types and current highest type
  for i=1, 16 do
	if turtle.getItemCount(i) > 0 then
	  turtle.select(i)
	  for k=1, count do
		if turtle.compareTo(getRep(k, types)) then types[i] = k end
	  end
	  if not types[i] then
		count = count + 1
		types[i] = count
	  end
	
	end
  end
  return types, count
end
assignTypes goes through all the inventory slots and gives them sequential types by comparing them with other blocks. So if my slots were set up "cobble cobble torch ladder" then the function would return {1, 1, 2, 3,} and 3. This is useful because then only the order you put items in matters. You would then take that table of types, put it in "getRep" with a type you want, and it returns the first slot with that type in it. The getTableOfType function takes a table of types, and returns a table of all slots that have that type.
So just feel free to use this (or ideas from this) if you want. Also don't feel pressured to if this seems pushy…

The second thing is that although the structure it makes is awesome, it would be nice if there was an option to make a 1x1 hole, and just place the blocks around it and a ladder below it. If that is too difficult or out of scope, though, don't worry about it.
Edited on 27 May 2014 - 01:16 AM
Ion Silverbolt #3
Posted 26 May 2014 - 06:16 PM
Thanks for the kind words. :)/>

Those are some things I wouldn't mind looking into. At the very least I should add a help argument. I'm still fairly new to lua, but i'm learning.

The 1x1 tunnel option I will work on. That shouldn't be hard to code. I personally don't like narrow tunnels, otherwise it probably makes more sense to make it narrow. :)/>
TDplay #4
Posted 31 May 2014 - 11:14 PM
I like it. If they made advanced turtles faster, it would probably take less time. It does take a long time but…

Thanks for the kind words. :)/>

Those are some things I wouldn't mind looking into. At the very least I should add a help argument. I'm still fairly new to lua, but i'm learning.

The 1x1 tunnel option I will work on. That shouldn't be hard to code. I personally don't like narrow tunnels, otherwise it probably makes more sense to make it narrow. :)/>

The 1x1 option would make it faster too!