4 posts
Posted 08 September 2012 - 08:36 PM
Im trying to code mining turtle so it'll dig 6x6 area
repeat
turtle.digDown()
turtle.down()
turtle.digDown()
turtle.up()
turtle.forward()
until(6)
how i end the first reapet code and make it turn right and do the same??
(probbly easy to do but im new :/ )
318 posts
Location
Somewhere on the planet called earth
Posted 08 September 2012 - 08:39 PM
Repeat works like this:
sPoint = 1 --Set it as one at the start
repeat
--Stuff
--Stuff
--We do often have a var the get increased in here or we use a function to retrive and number and store it
--In this example i'll use a var that increases:
sPoint = sPoint + 1 --We increase sPoint by 1
until sPoint == 10 --When sPoint reaches 10 it will end
Will try to look at code now
Code: i belive this works
Spoiler
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
print("Done")
209 posts
Location
In your fridge.
Posted 08 September 2012 - 08:43 PM
For this, instead of a repeat loop, try a for loop.
for i = 1,6 do
turtle.digDown()
turtle.down()
turtle.digDown()
turtle.up()
turtle.forward()
end
Then you can make the rest of the code, and after 6 iterations of this, it will do the rest of it.
4 posts
Posted 08 September 2012 - 09:30 PM
Repeat works like this:
sPoint = 1 --Set it as one at the start
repeat
--Stuff
--Stuff
--We do often have a var the get increased in here or we use a function to retrive and number and store it
--In this example i'll use a var that increases:
sPoint = sPoint + 1 --We increase sPoint by 1
until sPoint == 10 --When sPoint reaches 10 it will end
Will try to look at code now
Code: i belive this works
Spoiler
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("right")
for i = 1, 6 do
turtle.digDown()
turtle.forward()
turtle.back()
turtle.turn("left")
end
print("Done")
when i tried that, it said: "bios206: [string "name"]:28: 'then' expected
1111 posts
Location
Portland OR
Posted 08 September 2012 - 09:35 PM
turtle.turn("left") is actually turtle.turnLeft(), and turtle.turn("right") is turtle.turnRight()
4 posts
Posted 08 September 2012 - 10:01 PM
and after i make that work, how i detect if inventory is full and tell it go back and empty the inventroy?
209 posts
Location
In your fridge.
Posted 08 September 2012 - 11:09 PM
if turtle.getItemCount(last free slot) >= 1 then
--do stuff
end
Just put in a slot that's the last free slot (for instance, if you have torches in slot 9, have it select 8) and then make the return program.
4 posts
Posted 09 September 2012 - 06:42 PM
ok, thanks for all!