Guidelime

Guidelime

4M Downloads

automatic detection for [F]

max-ri opened this issue ยท 2 comments

commented
  • automatically select flight point from the map
  • suggested by drsnuggles#6239
commented

syntax would neeed to be changed to e.g. "Fly to [F Thelsamar]" (like #10, #11)

commented

Can't test it but basically it should work this way
Taxi node names can found here https://github.com/Hoizame/WoW_ClassicUIResources/blob/master/RawData/TaxiNodes.lua
if you need them in all languages just tell me and i send you a luatable with them

local function TakeFlight(name)
	local mapID = C_Map.GetBestMapForUnit("player")
	if not mapID then return end -- no mapID for player found
	
	-- https://wow.gamepedia.com/API_C_TaxiMap.GetAllTaxiNodes
	local taxiNodes = C_TaxiMap.GetAllTaxiNodes(mapID)
	for i = 1, #taxiNodes do
		local taxiNodeData = taxiNodes[i]
		if taxiNodeData.name == name then
			if taxiNodeData.state == Enum.FlightPathState.Reachable then
				if IsMounted() then Dismount() end -- dismount befor use the flightpoint
				TakeTaxiNode(taxiNodeData.slotIndex)
			elseif taxiNodeData.state == Enum.FlightPathState.Current then
				-- we are on this flightpoint
			else
				-- Flight point not reachable
			end
		end
	end
end

-- Check if a flightpoint is used
-- RegisterEvent("PLAYER_CONTROL_LOST")
local function OnEvent(self, event)
	if event == "PLAYER_CONTROL_LOST" and UnitOnTaxi("player") then
		-- flight point taken
	end
end