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

[Turtle Quarry Program] Turtle Quarry Line Up Program.

Started by plazter, 29 September 2013 - 09:18 PM
plazter #1
Posted 29 September 2013 - 11:18 PM
Hello again people!

- i saw a topic last night, about a turtle setting up a quarry (from BuildCraft) so i decided to try make my own :D/>

So far i've got it working and all, but it will not clear out the area since its a engineering turtle sadly that is, but im gonna make it so that it will jump into the air to place the stuff it has to

Link: http://pastebin.com/wvMj4dQ5

Version: 1.0.0
Spoiler

local quarry = 13
local tesseract = 16
local landmark = 15
local chest = 14
local args = {...}
local length = 10

function checkFuel()
term.clear()
term.setCursorPos(1,1)
  print("Checking if i have enough fuel..")

  sleep(2)

if turtle.getFuelLevel() >= 500 then
  print("Im fine on fuel thanks.. press enter to continue.")
	while true do
	local event, key = os.pullEvent("key")
	 if key == keys.enter then
	  return
	 end
	end
   end
end

function lenght()
term.clear()
term.setCursorPos(1,1)
  print("How big do you want the quarry?")
  input = read()

if input then
length = input
   elseif input == nil then
print("Error..")
   end

  print("You have said that you want the quarry to be: ".. tostring(length))
   print("Are you sure?")
	print("Press Y/N")

  while true do
   local event, key = os.pullEvent("key")
	if key == keys.y then
	 print("I'm gonna go a head and build you quarry!")
	sleep(2)
	Quarry()
	end
	if key == keys.n then
	 print("You pressed N, breaking the program..")
	break
	end
  end
end

   function Quarry()
-- [ Landmarks ] --	
   for i = 1,length do
	 turtle.forward()
	end

	turtle.select(landmark)
	turtle.place()

	for o = 1, length -1  do
	 turtle.back()
	end

  turtle.turnRight()

  for p = 1,length do
   turtle.forward()
   end

   turtle.place()

  for a = 1, length do
   turtle.back()
  end

  turtle.turnLeft()
  turtle.back()
  turtle.place()
  turtle.attack()
-- [ Landmarks end] --
  turtle.back()
  turtle.select(quarry)
  turtle.place()
  turtle.up()
  turtle.select(chest)
  turtle.place()
  turtle.back()
  turtle.down()
  turtle.select(tesseract)
  turtle.place()
  print("Done.")

  end
		 function itemsSlot()
		  term.clear()
term.setCursorPos(1,1)
print("Place following items in slot:")
print("Quarry: 13")
print("Chest: 14")
print("Landmarks: 15")
print("Tesseract: 16")
sleep(5)
end
-- [Main program] --	  
itemsSlot()
checkFuel()
lenght()

New version: v.1.0.1
Spoiler

local block = 1
local quarry = 13
local tesseract = 16
local landmark = 15
local chest = 14
local args = {...}
local length = 10
local height = 0

function height()
  term.clear()
term.setCursorPos(1,1)
print("Do you wish the turtle to setup the quarry in air?")
print("Press Y/N to confirm")
  local event, key = os.pullEvent("key")
   if key == keys.y then
	  print("How far up?")
		input = read()
	 if input then
	height = tonumber(input)
   end
return
end
end

function checkFuel()
term.clear()
term.setCursorPos(1,1)
  print("Checking if i have enough fuel..")
  sleep(2)

if turtle.getFuelLevel() >= 500 then
  print("Im fine on fuel thanks.. press enter to continue.")
	while true do
	local event, key = os.pullEvent("key")
	 if key == keys.enter then
	  return
	 end
	end
   end
end

function lenght()
term.clear()
term.setCursorPos(1,1)
  print("How big do you want the quarry?")
  input = read()
if input then
length = input
   elseif input == nil then
print("Error..")
   end

  print("You have said that you want the quarry to be: ".. tostring(length))
   print("Are you sure?")
	print("Press Y/N")

  while true do
   local event, key = os.pullEvent("key")
	if key == keys.y then
	 print("I'm gonna go a head and build you quarry!")
	sleep(2)
	Quarry()
	end
	if key == keys.n then
	 print("You pressed N, breaking the program..")
	break
	end
  end
end
   function Quarry()
for i = 0, height do
turtle.up()
end
-- [ Landmarks ] --  
   for i = 1,length do
	 turtle.forward()
	end
turtle.select(block)	
turtle.forward()
turtle.placeDown()
turtle.back()
	turtle.select(landmark)
	turtle.place()
  
	for o = 1, length -1  do
	 turtle.back()
	end

  turtle.turnRight()

  for p = 1,length do
   turtle.forward()
   end
  
turtle.select(block)	
turtle.forward()
turtle.placeDown()
turtle.back()
turtle.select(landmark)
   turtle.place()

  for a = 1, length do
   turtle.back()
  end

  turtle.turnLeft()
turtle.select(block)
turtle.placeDown()
turtle.back()
turtle.select(landmark)
  turtle.place()
  turtle.attack()
-- [ Landmarks end] --
  turtle.back()
  turtle.select(quarry)
  turtle.place()
  turtle.up()
  turtle.select(chest)
  turtle.place()
  turtle.back()
  turtle.down()
  turtle.select(tesseract)
  turtle.place()
  print("Done.")
  for i = 0, height do
  turtle.down()
  end
  end
		 function itemsSlot()
		  term.clear()
term.setCursorPos(1,1)
print("Place following items in slot:")
print("Block for air placement: 1")
print("Quarry: 13")
print("Chest: 14")
print("Landmarks: 15")
print("Tesseract: 16")
sleep(5)
end
-- [Main program] --	
itemsSlot()
checkFuel()
height()
lenght()

BUG FIXED:
- Fuel check has been fixed a new Pastebin link has been given.

BUGS NEED TO FIX:
- When you Press N on the air bit, it will continue but will crash as it's gonna go make your quarry, will fix this when i figure out how :)/>


Hope you like it :)/>

theres an ingame guide that tells where to put things in slots :)/>

Regard Plazter
deFENCE_ #2
Posted 31 October 2013 - 03:36 AM
BUGS NEED TO FIX:
- When you Press N on the air bit, it will continue but will crash as it's gonna go make your quarry, will fix this when i figure out how :)/>


function height()
  term.clear()
term.setCursorPos(1,1)
print("Do you wish the turtle to setup the quarry in air?")
print("Press Y/N to confirm")
  local event, key = os.pullEvent("key")
   if key == keys.y then
          print("How far up?")
                input = read()
         if input then
        height = tonumber(input)
   else
     height = 0
   end
return
end
end


Take this. Didn't test it, but it should work.
valithor #3
Posted 31 October 2013 - 04:30 PM
BUGS NEED TO FIX:
- When you Press N on the air bit, it will continue but will crash as it's gonna go make your quarry, will fix this when i figure out how :)/>


function height()
  term.clear()
term.setCursorPos(1,1)
print("Do you wish the turtle to setup the quarry in air?")
print("Press Y/N to confirm")
  local event, key = os.pullEvent("key")
   if key == keys.y then
		  print("How far up?")
				input = read()
		 if input then
		height = tonumber(input)
   else
	 height = 0
   end
return
end
end


Take this. Didn't test it, but it should work.

you will also want to add

if tonumber(input) != nil then
  height = tonumber(input)
else
  height = 0
end


This will make it to where if the variable input is a string and not a number it will not crash put it where "if input then" is and it should work


function height()
  term.clear()
  term.setCursorPos(1,1)
  print("Do you wish the turtle to setup the quarry in air?")
  print("Press Y/N to confirm")
    local event, key = os.pullEvent("key")
    if key == keys.y then
	  print("How far up?")
	    input = read()
	  if tonumber(input) ~= nil then
	    height = tonumber(input)
	  else
	    height = 0
	  end
    else
	  height = 0
    end
    return
end