Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --GPS v1.2
- --SAVE AS "mygps"
- tArgs = {...}
- function autoUpdate()
- offv = fs.open("mygps","r")
- onv = http.get("http://pastebin.com/raw.php?i=NZdC82A2")
- if offv.readAll() ~= onv.readAll() then
- shell.run("clear")
- offv.close()
- print("Would you like to updaye (y/n)")
- if read() == "y" then
- print("Okay Updating...")
- print("Downloading newer version")
- shell.run("pastebin get NZdC82A2 mygpsUPDATE")
- print("Downloaded!")
- print("Deleting older version")
- fs.delete("mygps")
- print("Deleted!")
- print("Finishing...")
- fs.move("mygpsUPDATE","mygps")
- shell.run()
- print("Done Updating!")
- error()
- end
- end
- end
- autoUpdate()
- currentLab = os.getComputerLabel()
- if tArgs[1] == nil and fs.isDir("bases") == true then
- print("Usage: mygps <location/add/delete/help>")
- error()
- end
- if tArgs[1] == "add" then
- shell.run("clear")
- print("Name of area/base?")
- name = read()
- shell.run("clear")
- print("What is the x cordinate?")
- xcord = read()
- shell.run("clear")
- print("What is the y cordinate?")
- ycord = read()
- shell.run("clear")
- print("What is the z cordinate?")
- zcord = read()
- shell.run("clear")
- repeat
- print("Is this correct? (y/n)")
- print("Area Name: "..name)
- print("X Cord: "..xcord)
- print("Y Cord: "..ycord)
- print("Z Cord: "..zcord)
- input = read()
- if input == "y" then
- baseFile = fs.open("bases/"..tostring(name),"w")
- baseFile.writeLine(tostring(xcord))
- baseFile.writeLine(tostring(ycord))
- baseFile.writeLine(tostring(zcord))
- baseFile.close()
- shell.run("clear")
- print("Okay! Area created!")
- elseif input == "n" then
- shell.run("clear")
- print("Okay! Area not created!")
- end
- until input == "n" or input == "y"
- error()
- end
- if tArgs[1] == "delete" then
- shell.run("clear")
- print("Name of area/base?")
- name = read()
- if fs.exists("bases/"..name) == true then
- shell.run("clear")
- print("Are you sure you want to delete the location "..name.."? (y/n)")
- input = read()
- if input == "y" then
- fs.delete("bases/"..name)
- shell.run("clear")
- print("Deleted!")
- error()
- elseif input == "n" then
- print("Deletion canceled!")
- error()
- end
- else
- printError("Location not found")
- error()
- end
- end
- if fs.isDir("bases") == false then
- shell.run("clear")
- print("Bases directory does no exist.")
- print("Would you like to make one? (y/n)")
- input = read()
- if input == "y" then
- shell.run("clear")
- print("Creating directory...")
- fs.makeDir("bases")
- baseFile = fs.open("bases/example","w")
- baseFile.writeLine("--This is the format--")
- baseFile.writeLine("(The x Cord) -369")
- baseFile.writeLine("(The y Cord) 52")
- baseFile.writeLine("(The z Cord) 869")
- baseFile.close()
- shell.run("clear")
- print("Done! Type <where add> to add a location")
- error()
- else
- print("Directory is required! Goodbye!")
- error()
- end
- end
- if fs.exists("bases/"..tArgs[1]) == true then
- data = fs.open("bases/"..tArgs[1],"r")
- x = data.readLine()
- y = data.readLine()
- z = data.readLine()
- data.close()
- else
- printError("Location not recorded")
- error()
- end
- base = vector.new(x,y,z)
- current = vector.new(gps.locate()):round()
- path = current-base
- function go()
- while true do
- shell.run("clear")
- print("To get to "..tArgs[1].."...")
- current = vector.new(gps.locate()):round()
- path = current-base
- if path.x > 1 then
- print("Go "..(path.x).." Blocks West")
- xP = ((path.x).." Blocks West")
- elseif path.x < -1 then
- print("Go "..math.abs(path.x).." Blocks East")
- xP = (math.abs(path.x).. " Blocks East")
- else
- xP = (" ")
- end
- if path.z > 1 then
- print("Go "..path.z.." Blocks North")
- if xP ~= " " then
- os.setComputerLabel("Go "..(path.z).." Blocks North and "..xP)
- elseif xP == " " then
- os.setComputerLabel("Go "..(path.z).." Blocks North "..xP)
- end
- elseif path.z < -1 then
- print("Go "..math.abs(path.z).." Blocks South")
- if xP ~= " " then
- os.setComputerLabel("Go "..math.abs(path.z).." Blocks South and "..xP)
- elseif xP == " " then
- os.setComputerLabel("Go "..math.abs(path.z).." Blocks South "..xP)
- end
- else
- os.setComputerLabel("Go "..xP)
- end
- if math.abs(path.x) < 5 and math.abs(path.z) < 5 then
- shell.run("clear")
- print("You are at the location!")
- os.setComputerLabel("You are at the location!")
- sleep(.5)
- os.setComputerLabel(currentLab)
- error()
- end
- print()
- print("The cordinates are "..x.." "..y.." "..z)
- sleep(.1)
- end
- end
- function exit()
- event,p1,p2,p3 = os.pullEvent()
- if key.getName(p1) == "t" and event == "key" then
- os.setComputerLabel(currentLab)
- shell.run("clear")
- print("Canceled")
- end
- end
- parallel.waitForAny(go(),exit())
- os.setComputerLabel(currentLab)
Advertisement
Add Comment
Please, Sign In to add comment