Jump to content

Grabbing the users location


Landondena

Recommended Posts

I am working on a Wherigo where I want to know the users distance from a location. I don't want the user to know the location but I want to be able to tell them the distance. How can I make this happen? I'm using urwigo been playing around with it for several days. If i'm able to pull the users GPS Coordinates I can calculate the distance behind scenes. Any ideas?

Link to comment

I am working on a Wherigo where I want to know the users distance from a location. I don't want the user to know the location but I want to be able to tell them the distance. How can I make this happen? I'm using urwigo been playing around with it for several days. If i'm able to pull the users GPS Coordinates I can calculate the distance behind scenes. Any ideas?

 

You can create zones around the target-location and that way you'll be able to know where he is by the zones he already crossed...

Something like this:

zzones.jpg

Link to comment
I am working on a Wherigo where I want to know the users distance from a location...

 

This is something that I have inside my Wherigo. I'm not sure how you are to put it inside yours.

 

cartGeocacheotopia.MsgBoxCBFuncs.MsgBoxCB1 = function(action)
   --Check for GPS signal.  If good, move on.
   --If not, Turtle will say that they need a better signal from the heavens above, so restart the cartridge.
   uv = Env.DeviceID
   wx = Player.ObjectLocation.altitude:GetValue(ft)
   yz = Player.PositionAccuracy:GetValue(ft)
   if ((Wherigo.NoCaseEquals(uv,"DeskTop")) or (wx < 3) or (yz <= 3) or (yz > 150)) and (testmode < 1) then
       --if Turtle does not allow Player to go on, then CB10
       Wherigo.MessageBox{Text=[[You are looking for GEOCACHEOTOPIA; I know this.]],Media=zmediaturtle,Buttons={"Wow! You're good.",},Callback=cartGeocacheotopia.MsgBoxCBFuncs.MsgBoxCB10}
   else --else Turtle lets them pass
       Wherigo.MessageBox{Text=[[You are looking for GEOCACHEOTOPIA; I know this. I think you are finally ready.]],Media=zmediaturtle,Buttons={"Wow! You're good.",},Callback=cartGeocacheotopia.MsgBoxCBFuncs.MsgBoxCB2}
   end --if
end --CB1

cartGeocacheotopia.MsgBoxCBFuncs.MsgBoxCB10 = function(action)
   --Tell Player to restart and try again.
   Wherigo.MessageBox{Text=[[unfortunately, your ability to communicate with the GPS heavens above is not quite adequate at the moment.  Go get a good signal and restart this Wherigo cartridge.  We will continue then.]],Media=zmediaturtle,Buttons={"I'll be back.",},Callback=cartGeocacheotopia.MsgBoxCBFuncs.MsgBoxCB11}
end --CB10

Link to comment

I have several utility functions within my Battleship cartridge, which is easier to read and understand than Whack-A-Lackey. Both cartridges are open source, so feel free to look around. Battleship is well-commented and organized.

 

Here's one of the functions you might find useful:

function DistanceFromZone(zone, units)
local d2,b2 = Wherigo.VectorToPoint(Player.ObjectLocation, zone.OriginalPoint)
local d = d2(units)
--print("Distance from zone " .. zone.Name .. " = " .. d)
return d
end

 

You give it a zone and units (e.g. feet, meters) and it will tell you how far the player is from that zone in those units. Simple, and exactly what you wanted: it'll tell you the player's distance from a certain location. You could also modify it to accept coordinates if you'd like, as both parameters of VectorToPoint are coordinates (note: I have not tested this):

function DistanceFromCoords(latitude, longitude, units)
local d2,b2 = Wherigo.VectorToPoint(Player.ObjectLocation, Wherigo.ZonePoint(latitude, longitude))
local d = d2(units)
--print("Distance from coords " .. zone.Name .. " = " .. d)
return d
end

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...