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

How do I make a Turtle place Torch's?

Started by Popeye, 14 April 2013 - 06:32 AM
Popeye #1
Posted 14 April 2013 - 08:32 AM
Hello,

I am trying to make a program that will Place a Torch then move Forward and place another.

So… could anyone Help me?

Thanks.
Spongy141 #2
Posted 14 April 2013 - 08:41 AM
Easy

turtle.refuel(1) -- Make sure you have fuel :P/>/>/>/>
turtle.place(2,4)  -- Make sure the torch is on slot 2-4 so you don't run out easy
turtle.forward()
Now to make that constant, do "while true do" or "for i = 1, <How many times you want the turtle to move> do" then make sure for both of those to do "end" at the end of your code. Or if you want to know more about .turtle API go here
SO it should look like this when doing the for loop

turtle.refuel -- Either have the turtle fully fueled, or input this into the for loop
for i = 1,20 do -- You can change 20 anytime, but the 20 means how long it will travel
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.place(2,4)  -- Make sure your torches are in slots 2-4.
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward()
end
Its basically the same if your doing a while true do loop, but I do not recommend it. Since with the for loop you have more control with your turtle.
SuicidalSTDz #3
Posted 14 April 2013 - 08:45 AM
Make sure the turtle is one block away from the block it is facing or else turtle.place will return false.
Popeye #4
Posted 14 April 2013 - 09:12 AM
Easy

turtle.refuel(1) -- Make sure you have fuel :P/>/>/>/>
turtle.place(2,4)  -- Make sure the torch is on slot 2-4 so you don't run out easy
turtle.forward()
Now to make that constant, do "while true do" or "for i = 1, <How many times you want the turtle to move> do" then make sure for both of those to do "end" at the end of your code. Or if you want to know more about .turtle API go here
SO it should look like this when doing the for loop

turtle.refuel -- Either have the turtle fully fueled, or input this into the for loop
for i = 1,20 -- You can change 20 anytime, but the 20 means how long it will travel
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.place(2,4)  -- Make sure your torches are in slots 2-4.
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward()
end
Its basically the same if your doing a while true do loop, but I do not recommend it. Since with the for loop you have more control with your turtle.

My Code is:

turtle.refuel(1)
for i = 1,20
   turtle.turnLeft()
   turtle.turnLeft()
   turtle.place(2, 4)

   turtle.turnRight()
   turtle.turnRight()
   turtle.forward()
end

That does not work for me.
SuicidalSTDz #5
Posted 14 April 2013 - 09:24 AM
Replace turtle.place(2,4) with

turtle.select(2)
turtle.place()
Popeye #6
Posted 14 April 2013 - 09:42 AM
Also, I get an error saying

"bios:337: [string "Torch"]:3: 'do' expected"

My Code:


turtle.refuel(1)
for i = 1,20
turtle.turnLeft()
turtle.turnLeft()

turtle
.select(2)
turtle.place()

turtle.turnRight()
turtle.turnRight()
turtle.forward()
end


Could you help me with that?
remiX #7
Posted 14 April 2013 - 09:43 AM
For I = 1, 20 do

You left the do out
Popeye #8
Posted 14 April 2013 - 09:50 AM
A Big Thank you to all of you guys!

I have got it working!

Great Thanks!