Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --UPDATE SGPS
- local towerdata = http.get("http://pastebin.com/raw.php?i=MCCNBq1a").readAll()
- local fl = fs.open("data/twrs", "w")
- fl.write(towerdata)
- fl.close()
- local h = fs.open("data/twrs", "r")
- towers = h.readAll()
- fl.close()
- --END UPDATE SGPS
- args = {...}
- local towerstable = textutils.unserialize(towers)
- local function getClosestTower()
- local twrst = {}
- local twrsn = {}
- for k,v in pairs(towerstable) do
- local t = v[x]+v[y]+v[z]
- table.insert(twrst, k)
- table.insert(twrsn, t)
- end
- local num = math.max(unpack(twrsn))
- local name = ""
- for k,v in pairs(items) do
- if(v==num) then
- name = k
- end
- end
- return name
- end
- if args[1] == "locate" then
- local loc = gps.locate()
- --local loctext = loc[1]..", "..loc[2]..", "..loc[3]
- --print("You are at: "..loctext..".")
- print("Your closest tower is: "..getClosestTower())
- end
Advertisement
Add Comment
Please, Sign In to add comment