Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args={...}
- numX = tonumber(args[1])
- numY = tonumber(args[2])
- numZ = tonumber(args[3])
- local x = 0
- local y = 0
- local z = 0
- local dXZ = "z"
- local dY = "y"
- local count = 0
- local startX = -282
- local startY = 72
- local startZ = 564
- function Forward()
- print("forward")
- turtle.forward()
- if dXZ == "z" then z = z + 1
- elseif dXZ == "-z" then z = z - 1
- elseif dXZ == "x" then x = x + 1
- elseif dXZ == "-x" then x = x - 1
- end
- end
- function ChooseTurn(z)
- if dXZ == "x" and z > 0 then
- print("left")
- turtle.turnLeft()
- dXZ = "z"
- elseif dXZ == "x" and z < 0 then
- print("right")
- turtle.turnRight()
- dXZ = "-z"
- elseif dXZ == "-x" and z > 0 then
- print("right")
- turtle.turnRight()
- dXZ = "z"
- elseif dXZ == "-x" and z < 0 then
- print("left")
- turtle.turnLeft()
- dXZ = "-z"
- end
- end
- function ifPosX(x)
- if x > 0 then
- count = x
- dXZ = "x"
- turtle.turnRight()
- else
- count = x * (-1)
- dXZ = "-x"
- turtle.turnLeft()
- end
- end
- function ForwardX(x)
- ifPosX(x)
- for i= 1,count do
- Forward()
- end
- end
- function ifPosZ(z)
- if z > 0 then
- count = z
- else
- count = z * (-1)
- end
- end
- function ForwardZ(z)
- ifPosZ(z)
- for i=1,count do
- Forward()
- end
- end
- function UpDown()
- if dY == "y" then
- y = y + 1
- print("up")
- turtle.up()
- elseif dY == "-y" then
- y = y - 1
- print("down")
- turtle.down()
- end
- end
- function ifPosY(y)
- if y > 0 then
- dY = "y"
- count = y
- else
- dY = "-y"
- count = y * (-1)
- end
- end
- function UpDownY(y)
- ifPosY(y)
- for i=1,count do
- UpDown()
- end
- end
- function Print()
- print("x = ".. x)
- print("y = ".. y)
- print("z = ".. z)
- print("dXZ = "..dXZ)
- end
- function GetPoint(numX,numY,numZ)
- ForwardX(numX)
- print("dXZ = "..dXZ)
- UpDownY(numY)
- print("dY = "..dY)
- ChooseTurn(numZ)
- ForwardZ(numZ)
- print("dXZ = "..dXZ)
- end
- GetPoint(numX,numY,numZ)
- Print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement