Is there a macro that can place/send coordinates to the chat?
I know you can print coordinates this way:
/run local s,id,c,x,y=function()print(“No”)end,C_Map.GetBestMapForUnit(“player”)if not id then s()return end c=C_Map.GetPlayerMapPosition(id,“player”)if not c then s()return end x,y=c:GetXY()print(string.format("%s:%.2f,%.2f",GetZoneText(),x100,y100))
But is there a way to send the coordinates to a channel or to /say?
I’m sure it is possible because on retail there are addons which are posting coordinates of spotted rare elite. You can look for one for classic i suppose.
It’s not possible to throw all this into a macro due to that 255 character limit you mentioned, but as an alternative, you can write a script and include the script as an addon in your WoW client. This route has no character limit, and allows you to bind the logic to a command like /loc which can then be macroed if you want the script to execute with a button press.
Going this route, below script will do what you asked for:
SLASH_LOC1 = "/loc";
SlashCmdList["LOC"] = function(arg)
local id = C_Map.GetBestMapForUnit("player")
if not id then
print("No");
return;
end
local pos = C_Map.GetPlayerMapPosition(id, "player");
if not pos then
print("No");
return;
end
local x,y = pos:GetXY();
local output = string.format("%s:%.2f,%.2f",GetZoneText(),x100,y100);
if arg == 'say' then
SendChatMessage(output, "SAY");
elseif arg == 'party' then
SendChatMessage(output, "PARTY");
elseif arg == 'raid' then
SendChatMessage(output, "RAID");
elseif arg == 'general' then
local channelId;
for i=1,20,1 do
local id, name = GetChannelName(i);
if(string.find(name:lower(), "general") ~= nil) then
channelId = i;
break;
end
end
SendChatMessage(output, "CHANNEL", nil, channelId);
else
print(output);
end
end
In this example, i added parameters so you can do /loc say, /loc party, /loc general, etc. to specify where the mesage should be sent to.
You can use https://addon.bool.no. to turn this script into an addon. Install the addon into WoW\\\_classic\_\Interface\Addons.