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

Pigmen Gold mining robot script.

Started by Chaoscode, 25 May 2014 - 10:57 AM
Chaoscode #1
Posted 25 May 2014 - 12:57 PM

local valid = turtle.refuel(20)
local turn = 1;
print(valid)
while true do
if turtle.detect() then
  if turn == 1 then
   turtle.turnRight()
   turtle.forward()
   turtle.turnRight()
   turn = 0
  else
   turtle.turnLeft()
   turtle.forward()
   turtle.turnLeft()
   turn = 1
  end

else
  if turtle.forward()
   then
   print("Moving forward")
   if turtle.suck() then
	print("Picking up items")
   end
  else
   print("Mob Detected! Killing it")
   while turtle.forward() == false do
	turtle.attack()
   end
  
   if turtle.suck() then
	print("Picking up items")
   end
  
  end
end
end
BrianHernando #2
Posted 28 May 2014 - 01:07 AM
What exactly does this do..?
BlockSmith #3
Posted 01 June 2014 - 07:05 PM

local valid = turtle.refuel(20)
local turn = 1;
print(valid)

while true do
  if turtle.detect() then --This part of the if else statement seems to make the turtle turn around if it hits a block.
	  if turn == 1 then
	    turtle.turnRight()
	    turtle.forward()
	    turtle.turnRight()
	    turn = 0
	  else
	    turtle.turnLeft()
	    turtle.forward()
	    turtle.turnLeft()
	    turn = 1
	  end
  else  --This part moves the turtle forward and sucks up any items on the floor.
    if turtle.forward() then
	  print("Moving forward")
	  if turtle.suck() then
	    print("Picking up items")
	  end
    else  --If the turtle cannot move forward then attack
	 print("Mob Detected! Killing it")
	 while turtle.forward() == false do
	   turtle.attack()
	 end
 
	 if turtle.suck() then
	   print("Picking up items")
	 end
 
  end
end
end

Not the most efficient way, but it'd work.