Posted 26 November 2014 - 10:25 AM
I'm practicing my turtle programming so that i can program a more advanced mining program to my liking however i can't seem to get a basic if statement to work the way that i think it should be working. if you look near the bottom i try to make it so at the end of each forward row it checks to see if we are on the last row. and if it is it should not round off to the next row. but for some reason even though my x is equal to my width it runs as if it isn't. not quite sure how to fix this. this code can also be found at http://pastebin.com/50MC25UQ.
some other possibly needed information.
computer craft version: 1.58
server: techworld 2 v1.1.6
some other possibly needed information.
computer craft version: 1.58
server: techworld 2 v1.1.6
local tArgs = { ... }
if #tArgs ~= 3 then
print("Usage: mine <length> <width> <depth>")
return
end
local function move(x,y)
shell.run("move",x,y)
end
local function status(x,y,z,depth,width,length)
print("x="..x.." y="..y.." z="..z.." depth="..depth.." length="..length.." width="..width)
end
local length = tArgs[1] - 1
local width = tArgs[2]
local depth = tArgs[3]
local distance = tArgs[1] + tArgs[2] + tArgs[3]
local x=0
local y=0
local z=0
for z=1,depth do
for x=1,width do
for y=1,length do
status(x,y,z,depth,width,length)
turtle.dig()
move("f","1")
sleep(.1)
end
status(x,y,z,length,width,depth)
d=bit.band(x,1)
if x == a then
print("x=a")
else
if d==0 then
print("x does not equal width")
status(x,y,z,length,width,depth)
move("l","0")
turtle.dig()
move("f","1")
move("l","0")
elseif d==1 then
move("r","0")
turtle.dig()
move("f","1")
move("r","0")
else
move("f","0")
end
end
end
end