Originally Posted by CleetusTheDiabeetus
Hello All,
I was looking for some guidance on where to start for creating an AddOn with a UI that displays the closest Wayshrine to a player's position.
I need to: Determine Player PosX, PosY Find All Wayshrine Locations Calculate the closest wayshine from the players location Output that information to a UI Where can I pull player position?
Where can I get a list of wayshrines and their locations?
P.S:
I tried looking at the "FasterTravel" AddOn which determines the closest wayshrine to your quest but it was too advanced for me to figure out exactly what the functions they created were doing.
Thank you.
|
There is a complicated code in minimap by Fyrakin doing that which I improved because POI_TYPE_WAYSHRINE also includes non wayshrines (e. g. the harborage) but it is quite a work to extract the code.
in function
Lua Code:
function FyrMM.Wayshrines()
You do a loop with
Lua Code:
for nodeIndex = 1, GetNumFastTravelNodes() do
, get node info with
Lua Code:
GetFastTravelNodeInfo(nodeIndex)
then it is filtered to exclude houses and other non wayshrine stuff you can port to,
distance from each wayshrine is calculated with
Lua Code:
math.sqrt((player.nx-wayshrine.nX)*(player.nx-wayshrine.nX)+(player.ny-wayshrine.nY)*(player.ny-wayshrine.nY))
then you have to do a table with all your wayshrines and their distances (which will update when player moves) to find the closest.