170 posts
Posted 16 December 2012 - 12:30 AM
Title says it all!
Is there any way, other than turtle.compare(to a mining turtle in the inventory) to stop two mining turtles who bump into eachother from accidentally mining each other?
Context: a strip mining program where turtles excavate ore veins. When a vein spans across multiple levels both turtles could potentially encounter each other, messing up the array.
Answer:
if peripheral.getType("front") = "turtle" then
print("there is a turtle in front of me!")
end
Alternative:
if [color=#282828][font=helvetica, arial, sans-serif]peripheral.isPresent("front")[/font][/color] then
print("there is a CC block in front of me!")
end
7508 posts
Location
Australia
Posted 16 December 2012 - 12:36 AM
if you keep a turtle, in a turtle's inventory and use compare before digging it will stop it, but you loose a whole slot :(/>
170 posts
Posted 16 December 2012 - 12:43 AM
Can anybody think of any other options?
7508 posts
Location
Australia
Posted 16 December 2012 - 12:49 AM
Can anybody think of any other options?
Until the compare or detect options get updated (if ever) to get the block name or id there is no way.
170 posts
Posted 16 December 2012 - 12:52 AM
Can anybody think of any other options?
Until the compare or detect options get updated (if ever) to get the block name or id there is no way.
Ok thanks!
7508 posts
Location
Australia
Posted 16 December 2012 - 12:56 AM
Can anybody think of any other options?
Until the compare or detect options get updated (if ever) to get the block name or id there is no way.
Ok thanks!
Sorry I couldn't be the bearer of better news.
The best option is just do a server controlling them so they never collide.
I guess you could have them broadcast their location with rednet and where they are going to move, and if a turtle receives they say where they are and where they will move, and the original turtle hasnt dug until its all clear.
170 posts
Posted 16 December 2012 - 02:05 AM
I asked on the suggestions forum for something like turtle.detectTurtle() and got an answer:
It is possible to use "peripheral.getType(direction)" and get the type (turtle, modem, …) of the block in front.
So it is possible!
7508 posts
Location
Australia
Posted 16 December 2012 - 02:09 AM
I asked on the suggestions forum for something like turtle.detectTurtle() and got an answer:
It is possible to use "peripheral.getType(direction)" and get the type (turtle, modem, …) of the block in front.
So it is possible!
true i forgot about that, sorry. I would be more inclined to use peripheral.isPresent("front") that way it wont mine ANYTHING that CC related. :)/>
2005 posts
Posted 16 December 2012 - 09:42 AM
Ugh. Patience is a virtue. Particularly in the early morning.
If you're using a pullEvent cycle, then just check for "peripheral" events. But you're probably not.
170 posts
Posted 16 December 2012 - 10:37 AM
Ugh. Patience is a virtue. Particularly in the early morning.
If you're using a pullEvent cycle, then just check for "peripheral" events. But you're probably not.
The code would (in this case) not be embedded in a cycle, if the turtle detects another turtle in the direction he is headed there is no reason for him to go there (since the ores will already have been excavated) and he will back off.