Jump to content




ComputerCraft Mining Turtle Gravel check ideas?


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

#1 husplante

  • Members
  • 7 posts

Posted 03 July 2014 - 12:18 PM

Does anyone have a good idea of how i can improve this program so it will detect gravel and mine it out?
Btw This is my first program and i am only 12 so please dont do something super complicated.
:)

  • function turn180()

  • turtle.turnLeft()

  • turtle.turnLeft()

  • end

  • function up2()

  • turtle.up()

  • turtle.up()

  • end

  • function forward2()

  • turtle.forward()

  • turtle.forward()

  • end

  • function Dig3x3()

  • turtle.dig()

  • turtle.forward()

  • turtle.turnLeft()

  • turtle.dig()

  • turtle.digDown()

  • turtle.forward()

  • turtle.dig()

  • turtle.digDown()

  • turtle.down()

  • turtle.dig()

  • turtle.digDown()

  • turtle.forward()

  • turtle.digDown()

  • turn180()

  • forward2()

  • turtle.turnLeft()

  • turtle.digDown()

  • up2()

  • end

  • while turtle.getFuelLevel() ~= 0 and turtle.getItemCount(2) ~= 0 and turtle.getItemCount(16) ~= 1 do

  • Dig3x3()

  • Dig3x3()

  • Dig3x3()

  • Dig3x3()

  • Dig3x3()

  • turn180()

  • turtle.forward()

  • turtle.turnLeft()

  • turn180()

  • turtle.forward()

  • turn180()

  • turtle.select(2)

  • turtle.place(2)

  • turtle.turnLeft()

  • turtle.forward()

  • turtle.turnRight()

  • turtle.forward()

  • turtle.turnLeft()

  • end


#2 GamerNebulae

  • Members
  • 216 posts
  • LocationNetherlands

Posted 03 July 2014 - 01:34 PM

First of all, since you are new on the forums, always paste code in between the [.CODE] [/CODE] tags (without the dots). I made a branching program a long time ago and it still works fine. This is how it runs (assuming that you want it to wait when gravel falls down):
function notMoving()
	    while not turtle.forward() do
			    turtle.dig()
			    sleep(1)
	    end
end

While it cannot move forwards, it will dig in front of himself and he will then wait. If he cannot move again, then he will repeat the same thing over and over and over again.

Edited by GamerNebulae, 03 July 2014 - 01:36 PM.


#3 husplante

  • Members
  • 7 posts

Posted 03 July 2014 - 04:50 PM

Ty

#4 husplante

  • Members
  • 7 posts

Posted 03 July 2014 - 05:16 PM

IM just wondering why do you have 2 end lines?

#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 03 July 2014 - 05:22 PM

He's ending the function statement, and ending the while loop.

#6 husplante

  • Members
  • 7 posts

Posted 03 July 2014 - 06:15 PM

so i should do
if turtle.forward == false do
notMoving()

right?

#7 husplante

  • Members
  • 7 posts

Posted 03 July 2014 - 06:55 PM

Thank You for the help i made this now for my stripmine program thanks to what you teached me:)
[.Code]
function detectUp()
if turtle.detectUp() == true then
turtle.digUp()
sleep(1)
end
end

function Dig3x1()
turtle.dig()
if turtle.forward() == false then
turtle.dig()
sleep(1)
end
turtle.digUp()
detectUp()
turtle.digDown()
end

Dig3x1()
Dig3x1()
Dig3x1()
Dig3x1()
Dig3x1()
turtle.select(1)
turtle.placeDown()
[/Code]

#8 GamerNebulae

  • Members
  • 216 posts
  • LocationNetherlands

Posted 03 July 2014 - 08:05 PM

View Posthusplante, on 03 July 2014 - 06:55 PM, said:

-snip-

Just to shorten the code, I always use the keyword "not". It basically means "false". Example:
statement = false
if (not statement) then
  print("Statement was "..statement)
end
--#Output: Statement was false

The problem with your code at the moment is, it will run into a piece of gravel and if the stack of gravel is higher than 2, then it will not work. So please just use my code, otherwise it will not work.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users