Posted 29 March 2013 - 09:21 PM
I'm trying to create a mining system with an auto torch placement system, and I want to place a torch every 8 times I move (AKA, 8 times per loop). Here's the code:
x+1
if x == 8 then
local x = 0
…….
So it would reset itself, but I would have to declare X being 0 at the top, so it would reset itself every time.
local mf = 1
print("Please put fuel in slot 1")
print("Length?")
local length = read()
print("Do you want to place torches? (yes or no, no uppercase)")
local torchYN = read()
for i = 1, length do
if turtle.detect() == true then
turtle.dig()
end
turtle.forward()
if turtle.detectUp() == true then
turtle.digUp()
end
if turtle.getFuelLevel() < mf then
turtle.refuel(1)
end
[color=#0000ff]if torchYN == "yes" then
turtle.turnRight()
turtle.turnRight()
turtle.select(2)
turtle.place()
turtle.turnLeft()
turtle.turnLeft()
end[/color]
end
turtle.turnRight()
turtle.turnRight()
print("I'm on my way back")
for i = 1, length do
turtle.forward()
if turtle.getFuelLevel() < mf then
turtle.refuel(1)
end
end
print("I'm back at my starting position")
turtle.turnRight()
turtle.turnRight()
I was thinking when it started the torch placement part, it would do something like:x+1
if x == 8 then
local x = 0
…….
So it would reset itself, but I would have to declare X being 0 at the top, so it would reset itself every time.