Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = {...}
- if tArgs[1] == nil and fs.isDir("bases") == true then
- print("Usage: Where <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
- shell.run("clear")
- print("To get to "..tArgs[1].."...")
- if path.x > 30 then
- print("Go "..path.x.." Blocks West")
- elseif path.x < -30 then
- print("Go "..math.abs(path.x).." Blocks East")
- end
- if path.z > 30 then
- print("Go "..path.z.." Blocks North")
- elseif path.z < -30 then
- print("Go "..math.abs(path.z).." Blocks South")
- end
- if math.abs(path.x) < 30 and math.abs(path.z) < 30 then
- print("You are at the location!")
- end
- print()
- print("The cordinates are "..x.." "..y.." "..z)
Advertisement
Add Comment
Please, Sign In to add comment