Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _tArgs={...}
- fuel=turtle.getFuelLevel()
- print(os.getComputerID(),": ",os.getComputerLabel())
- print ("Fuel Level: ",fuel)
- if fuel>0 then
- rednet.open("right")
- if #_tArgs==2 and _tArgs[1]~=_tArgs[2]then
- pos1=vector.new(textutils.unserialize(_tArgs[1]))
- pos2=vector.new(textutils.unserialize(_tArgs[2]))
- else
- pos1=vector.new(gps.locate())
- while turtle.detect()==true do
- turtle.turnRight()
- end
- turtle.forward()
- pos2=vector.new(gps.locate())
- turtle.back()
- end
- posDelta=pos2-pos1
- local dirFile=fs.open("/nav/dir.tab","r")
- local dirData=dirFile.readAll()
- dirFile.close()
- local dirTab=textutils.unserialize(dirData)
- if posDelta.x==0 and posDelta.z==-1 then
- direction=2
- elseif posDelta.x==0 and posDelta.z==1 then
- direction=0
- elseif posDelta.x==-1 and posDelta.z==0 then
- direction=1
- elseif posDelta.x==1 and posDelta.z==0 then
- direction=3
- end
- print("Current Position: ",pos1)
- -- print(pos2)
- -- print(posDelta)
- -- print(posDelta.x)
- -- print(posDelta.z)
- print("Heading: ",dirTab[direction])
- local data={pos1.x,pos1.y, pos1.z, direction}
- -- for k, v in pairs (data) do
- -- print (v)
- -- end
- file=fs.open("/nav/gpsCoord","w")
- file.write(textutils.serialize(data))
- file.close()
- return direction
- else
- print("No Fuel!")
- i=1
- while fuel==0 do
- for i=1,16 do
- turtle.select(i)
- refuel=turtle.refuel()
- if refuel==true then
- fuel=turtle.getFuelLevel
- end
- print("refuel: ",refuel)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement