Jump to content

Bearing (to a zone or point)


jonny65

Recommended Posts

For lua freaks <_< ... how to realize this ... :

The player stays at a certain point and a small invisible zone is active. Now I want to know the bearing to these zone (or better a point ?) and the distance (for example 117°, 376 ft). Anyone who has a small function for this ?

Link to comment

Please see my Battleship cartridge for many utility functions you can copy and paste into your own cartridge.

 

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

This function will tell you the distance a player is from a certain zone. If you'd like to know the distance and bearing from any point, just put those to points as arguments to VectorToPoint. The first return value is a distance object (feed it a string representing units, such as "m") and the second is the bearing from the first point to the second.

 

Anyway, perhaps, as a community, we should come out with an entire library of helpful functions like this. Several are in Battleship; we can always add to them.

Link to comment

Ups, thats all ? Soooo simple ? The bearing is within "Wherigo.VectorToPoint" as a second argument turned back...ah...ok, thanks Ranger Fox. I appreciate, if, as you say, a library would come out, which includes not only the functions, but the usage with the builder. I think most of the Wherigo programmers don't know how to handle a complex function in the builder, call it, define unique (!) identifieres, read out the values and so on.

 

For example in that case, I placed the function in the section "lua user functions" in urwigo, define an interval timer and call the function from the elapse event of the timer. So everybody reproduce (see the snap) how it works together (urwigo and user function). In my beginning I not even know, where to write the lua function down. Perhaps in a message box ? <_<

 

post-3481440-047931600 1382632268_thumb.jpg

Link to comment

With regards to Urwigo, it might be good to have a clickable library listing a'la NuGet in Visual Studio. In other words, authors could pop up a box and look through a listing of available library functions and select which ones they want to include within their cartridge. Urwigo could handle function call relationship dependencies. After that, you could make the function call anywhere within the cartridge designer as if it was a normal part of Wherigo.

 

There are so many things to work on before Wherigo is usable for the masses...

Link to comment

The attached file has gone ... already again. I guess an important thing, the identifier of the zone must be set, otherwise the cartridge crashes

 

bearing_timer.jpg

 

Ranger : I would say it's better that Wherigo generally is too complex for the masses. It persists as an especially type of cache.

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...