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

Quarry Frame Script

Started by RevBlueJeans, 14 August 2013 - 10:56 PM
RevBlueJeans #1
Posted 15 August 2013 - 12:56 AM
I currently have 4 quarries running in the middle of the ocean. It has become a hassle to layout a 60x60 area of cobble stone each time I'm ready to fire up a new quarry, this is especially true since all of the quarries are in sync so I must build 4 60x60 cobblestone outlines so that I can place the landmarks and make sure the area is indeed 60x60. I decided to write a turtle script to automate this process. My goal is to have to turtle start where the first landmark will be, then build out in a straight line 60 blocks, turn right and build out another 60 blocks, turn right, another 60 blocks and finally turn right and the last 60 to reach it's initial starting area. The script I have written uses a nested loop, one to count to 4 since there are 4 sides and the nested loop to count to 60, once for each block length. The problem I'm having is that the turtle is not laying out the frame correctly. He does not go the full 60 block distance before turning right, he also does not select the next stack of items when he is low. Could someone please look at this script and see what I am doing wrong.

Thanks in advance!
-Rev


turtle.refuel()
local slotSelect = 2
turtle.select(slotSelect)
for i=1, 4 do
for j=1, 60 do
  if turtle.detectDown() then
   turtle.forward()
  else
   if turtle.getItemCount(slotSelect)==0 then
    slotSelect = slotSelect + 1
   end
   turtle.placeDown()
  end
end

turtle.turnRight()
end
Lyqyd #2
Posted 15 August 2013 - 02:53 PM
Split into new topic.

One problem is that you increment your slot selection variable, but then never actually select the new slot number.
connerity #3
Posted 15 August 2013 - 06:07 PM
Your program doesn't move the full 60 blocks forward because:

for j=1, 60 do
  if turtle.detectDown() then
   turtle.forward()
  else
     if turtle.getItemCount(slotSelect)==0 then
     slotSelect = slotSelect + 1
     end
   turtle.placeDown()
end
This goes through the loop twice for every space moved. Also, 60 is 1 block too far, you need to substract 1 for the corners.

Your code fixed and working would look something like this:
	
    turtle.select(1)
    turtle.refuel()
    slot=2
    turtle.select(slot)
     for i=1,4 do
      for i=1,59 do
         if not turtle.detectDown() then
         turtle.placeDown()
         turtle.forward()
         else
         turtle.forward()
         end
         if turtle.getItemCount(slot) == 0 then
         slot = slot+1
         turtle.select(slot)
         end
      end
     turtle.turnRight()
    end




Also, I'd suggest the following:
First of all, the "make sure that it's really 60x60" part can be skipped when not doing it manually.
So you only need to place 4 cobblestone in the corners.


turtle.select(1)
turtle.refuel()
turtle.select(2)
turtle.placeDown() --remove this if you place the first block yourself, currently, the turtle needs to start in air
for i=1,239 do
 if i = 60 or i = 120 or i = 180 then
 turtle.placeDown()
 turtle.turnRight()
 else
 turtle.forward()
 end
end
places the 4 corners and ends up at the first corner where it started. I left out the code for selecting more building block slots since it only uses 4 blocks.
RevBlueJeans #4
Posted 15 August 2013 - 09:55 PM
It's working now! Thank you so much this has saved me so much time and now I don't dread having to fire my quarries back up :P/> time to watch my AE system overflow once again!