Sorry for asking another question so fast, I am a good noob.
Is this code wrong? they ask for "then" at the first line and I am confused @.@
if curdirec= "4" then
turtle.turnRight()
print("1")
elseif curdirec = "1" then
print("1")
elseif curdirec = "2" then
turtle.turnLeft()
print("1")
elseif curdirec = "3" then
turtle.turnLeft()
print("0.5")
turtle.turnLeft()
print("1")
end
Thanks!This my full code:
local tArgs = {...}
local dx, dy, dz
local dx = tonumber(tArgs[1])
local dy = tonumber(tArgs[2])
local dz = tonumber(tArgs[3])
local x, y, z, dif
local nx, ny, nz
local gdcx, gdcy, gdcz
local mm = 1
local curdirec
local xtm, ytm, ztm
print("Target corrdinents: "..dx)
rednet.open("right")
x, y, z = gps.locate(5)
nx = x-0 --fixing the slight inaccuray
ny = y-1 --fixing the slight inaccuray
nz = z-2 --fixing the slight inaccuray
print("Current coordinents: "..nx)
--movement Script
if turtle.forward() then
turtle.forward()
gdcx, gdcy, gdcz = gps.locate(5)
print("New cooridinents: "..gdcx)
turtle.back()
turtle.back()
else
turtle.dig()
turtle.forward()
gdcx, gdcy, gdcz = gps.locate(5)
print("New cooridinents: "..gdcx)
turtle.back()
turtle.back()
end
--checking Script
if gdcx > nx then
curdirec = "4"
print("Current direction: West")
elseif gdcx < nx then
curdirec = "2"
print("Current direction: East")
elseif gdcz < nz then
curdirec = "1"
print("current direction: North")
elseif gdcz > nz then
curdirec = "3"
print("Current direction:South")
else
print("error detected, repeat setup")
end
if curdirec= "4" then
turtle.turnRight()
print("1")
elseif curdirec = "1" then
print("1")
elseif curdirec = "2" then
turtle.turnLeft()
print("1")
elseif curdirec = "3" then
turtle.turnLeft()
print("0.5")
turtle.turnLeft()
print("1")
end [/font]