Jump to content




easy 2x2 tunnel maker


  • You cannot reply to this topic
6 replies to this topic

#1 jeroentje402

  • New Members
  • 4 posts

Posted 11 March 2012 - 08:47 PM

i have made a easy code to let your turtle make a 2x2 tunnel ;)/> it's my first turtle script.

coded changed to(it's now realy fast :mellow:/> thanks shaftm):
print("creating a 2x2 tunnel")
loop = 1
while loop == 1 do
turtle.dig()
turtle.forward()
if turtle.detectUp() then
turtle.digUp()
turtle.up()
else
turtle.up()
end
turtle.turnRight()
turtle.dig()
if turtle.detectDown() then
turtle.digDown()
turtle.down()
else
turtle.down()
end
turtle.dig()
turtle.placeDown()
turtle.turnLeft()
end


#2 shaftm

  • New Members
  • 6 posts

Posted 12 March 2012 - 03:24 AM

Cool little script!
Why sleep/detect? Simpler to just skip it for something like this, imo.
Although without the sleeps it might lag? Idk
print("Creating a 2x2 tunnel")
loop = 1
while loop == 1 do
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.digDown()
turtle.down()
turtle.dig()
turtle.up()
turtle.turnRight()
turtle.dig()
end


#3 jeroentje402

  • New Members
  • 4 posts

Posted 12 March 2012 - 03:24 PM

View Postshaftm, on 12 March 2012 - 03:24 AM, said:

Cool little script!
Why sleep/detect? Simpler to just skip it for something like this, imo.
Although without the sleeps it might lag? Idk
print("Creating a 2x2 tunnel")
loop = 1
while loop == 1 do
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.digDown()
turtle.down()
turtle.dig()
turtle.up()
turtle.turnRight()
turtle.dig()
end

I have used the sleeps because Ithought the turtle will skip some code. but i'm not sure he will do that. the detect is for if the turtle find a lava lake it wil make a path for himself.

#4 metalic

  • New Members
  • 1 posts

Posted 15 March 2012 - 08:56 AM

Hi,
I like your code. I think there should be more simple operations in the library for new users to use.
Anyway, I think I may have found a flaw in your code (correct me if I am wrong):
if turtle.detectDown() then
turtle.placeDown()
I believe is intended to place blocks if there is no floor, right?
If so, shouldn't it be something more like:
if not turtle.detectDown() then
turtle.placeDown()
I am new to this, so high chances are that that isn't the right code.
Anyway, just wanted to help the learning/code.

#5 jeroentje402

  • New Members
  • 4 posts

Posted 21 March 2012 - 08:32 PM

View Postaprhys, on 15 March 2012 - 08:56 AM, said:

Hi,
I like your code. I think there should be more simple operations in the library for new users to use.
Anyway, I think I may have found a flaw in your code (correct me if I am wrong):
if turtle.detectDown() then
turtle.placeDown()
I believe is intended to place blocks if there is no floor, right?
If so, shouldn't it be something more like:
if not turtle.detectDown() then
turtle.placeDown()
I am new to this, so high chances are that that isn't the right code.
Anyway, just wanted to help the learning/code.

i know what you trying to say but look the code is this:
if turtle.detectDown() then
turtle.placeDown()
else
turtle.placeDown()
end

i did this:
if turtle.detectDown() then
turtle.placeDown()

because i want that i also place stone in lava ;p if the turtle code is like this:

if not turtle.detectDown() then
turtle.placeDown

What this says is if the turtle does not find a block below him he places a Block but. But if he Detects Lava or Water he see it as a Block (i think ;p) so he don't place a Block but whit this:

if turtle.detectDown() then
turtle.placeDown()
else
turtle.placeDown()
end

He places blocks in lava and Water :(/>
Sorry for the most crappy english ever :3

#6 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 21 March 2012 - 08:37 PM

View Postjeroentje402, on 21 March 2012 - 08:32 PM, said:

[...]
What this says is if the turtle does not find a block below him he places a Block but. But if he Detects Lava or Water he see it as a Block (i think ;p) so he don't place a Block but whit this:

if turtle.detectDown() then
turtle.placeDown()
else
turtle.placeDown()
end

He places blocks in lava and Water :(/>
Sorry for the most crappy english ever :3
But this will place a block down no matter what, so you could save yourself all these lines and just use:
turtle.placeDown()

#7 jeroentje402

  • New Members
  • 4 posts

Posted 21 March 2012 - 08:42 PM

View PostEspen, on 21 March 2012 - 08:37 PM, said:

View Postjeroentje402, on 21 March 2012 - 08:32 PM, said:

[...]
What this says is if the turtle does not find a block below him he places a Block but. But if he Detects Lava or Water he see it as a Block (i think ;p) so he don't place a Block but whit this:

if turtle.detectDown() then
turtle.placeDown()
else
turtle.placeDown()
end

He places blocks in lava and Water :)/>
Sorry for the most crappy english ever :3
But this will place a block down no matter what, so you could save yourself all these lines and just use:
turtle.placeDown()

mm yeah that true ;p thans i will change it :(/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users