Funky error occurring if there is a comment after the .xml file but not after the .toc file
(Initial upload) |
(Funky error occurring if there is a comment after the .xml file but not after the .toc file) |
||
| Line 1: | Line 1: | ||
I'll try to keep this brief. Note: The formatting alone makes this look longer than it really is. This AddOn will give you your characters (x, y) coordinates located under the Mini map and it will updated in real time as you move around. Minor programming experience with any language is recommended. | I'll try to keep this brief. Note: The formatting alone makes this look longer than it really is. This AddOn will give you your characters (x, y) coordinates located under the Mini map and it will updated in real time as you move around. Minor programming experience with any language is recommended. | ||
Begin: | Begin: | ||
| Line 20: | Line 20: | ||
==== eCoordinates.toc contents Start ==== | ==== eCoordinates.toc contents Start ==== | ||
## Interface: 60200 -- Required. game version. < | ## Interface: 60200 -- Required. game version. | ||
<nowiki>##</nowiki> Title: eCoordinates -- Name shown when viewing AddOn list | |||
<nowiki>##</nowiki> Version: 1.0 -- | |||
<nowiki>##</nowiki> Notes: Simple GPS -- Popup title seen with mouseover on AddOn title in load screen | |||
<nowiki>##</nowiki> Author: eSaith -- not require<br><br> | |||
eCoordinates.lua -- required, lets WoW know what to look for | |||
eCoordinates.lua -- required, lets WoW know what to look for | eCoordinates.xml | ||
eCoordinates.xml | |||
[ /run print((select(4, GetBuildInfo()))) ] -- Will give you your Interface number. Replace 60200 with your current version | [ /run print((select(4, GetBuildInfo()))) ] -- Will give you your Interface number. Replace 60200 with your current version | ||
==== eCoordinates.xml contents ==== | ==== eCoordinates.xml contents ==== | ||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd"> | <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd"> | ||
<Script File="eCoordinates.lua"/ | <Script File="eCoordinates.lua"/> | ||
<Frame name="eCoordinates" parent="UIParent"> | |||
<Frame name="eCoordinates" parent="UIParent" | <Scripts> | ||
<Scripts | <OnLoad function="eCoordinates_OnLoad"></OnLoad> | ||
<OnLoad function="eCoordinates_OnLoad"></OnLoad | <OnEvent function="eCoordinates_OnEvent"></OnEvent> | ||
<OnEvent function="eCoordinates_OnEvent"></OnEvent | </Scripts><br></Frame> | ||
</Scripts><br> | |||
</Ui> | </Ui> | ||
Bare bones: | Bare bones: | ||
| Line 62: | Line 59: | ||
eCoordinates.lua contents - programming. It may look like a lot, and a lot is happening but I will try to be as clear and concise as I can be. Don't fret if it takes a minute to figure out! | eCoordinates.lua contents - programming. It may look like a lot, and a lot is happening but I will try to be as clear and concise as I can be. Don't fret if it takes a minute to figure out! | ||
local zone = nil | local zone = nil | ||
local TimeSinceLastUpdate = 0<br> | local TimeSinceLastUpdate = 0<br> | ||
local function UpdateCoordinates(self, elapsed) | local function UpdateCoordinates(self, elapsed) | ||
if zone ~= GetRealZoneText() then<br> zone = GetRealZoneText()<br> SetMapToCurrentZone()<br> end<br> | |||
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed<br> | |||
if TimeSinceLastUpdate > .5 then <br> TimeSinceLastUpdate = 0<br> local posX, posY = GetPlayerMapPosition("player"); <br> local x = math.floor(posX * 10000)/100<br> local y = math.floor(posY*10000)/100<br> eCoordinatesFontString:SetText("|c98FB98ff("..x..", "..y..")") <br> | |||
end | |||
if TimeSinceLastUpdate > .5 then <br> | |||
end | |||
end<br> | end<br> | ||
function eCoordinates_OnLoad(self, event,...) | function eCoordinates_OnLoad(self, event,...) | ||
self:RegisterEvent("ADDON_LOADED") | self:RegisterEvent("ADDON_LOADED") | ||
end<br> | end<br> | ||
function eCoordinates_OnEvent(self, event, ...) <br> | function eCoordinates_OnEvent(self, event, ...) <br> | ||
if event == "ADDON_LOADED" and ... == "eCoordinates" then<br> | if event == "ADDON_LOADED" and ... == "eCoordinates" then<br> self:UnregisterEvent("ADDON_LOADED") <br> eCoordinates:SetSize(100, 50)<br> eCoordinates:SetPoint("TOP", "Minimap", "BOTTOM", 5, -5)<br> eCoordinates:SetScript("OnUpdate", UpdateCoordinates)<br> local coordsFont = eCoordinates:CreateFontString("eCoordinatesFontString", "ARTWORK", "GameFontNormal")<br> coordsFont:SetPoint("CENTER", "eCoordinates", "CENTER", 0, 0)<br> coordsFont:Show()<br> eCoordinates:Show() | ||
end | |||
end | |||
end | end | ||
| Line 100: | Line 79: | ||
Remember in the .xml file, line 5 we were looking for the first event OnLoad. | Remember in the .xml file, line 5 we were looking for the first event OnLoad. | ||
function eCoordinates_OnLoad(self, event,...) | function eCoordinates_OnLoad(self, event,...) | ||
self:RegisterEvent("ADDON_LOADED") <br> | self:RegisterEvent("ADDON_LOADED") <br> | ||
end | end | ||
| Line 119: | Line 98: | ||
function eCoordinates_OnEvent(self, event, ...) <br> | function eCoordinates_OnEvent(self, event, ...) <br> | ||
if event == "ADDON_LOADED" and ... == "eCoordinates" then<br> | if event == "ADDON_LOADED" and ... == "eCoordinates" then<br> | ||
self:UnregisterEvent("ADDON_LOADED") <br> eCoordinates:SetSize(100, 50)<br> eCoordinates:SetPoint("TOP", "Minimap", "BOTTOM", 5, -5)<br> eCoordinates:SetScript("OnUpdate", UpdateCoordinates)<br> local coordsFont = eCoordinates:CreateFontString("eCoordinatesFontString", "ARTWORK", "GameFontNormal")<br> | |||
coordsFont:SetPoint("CENTER", "eCoordinates", "CENTER", 0, 0)<br> coordsFont:Show()<br> eCoordinates:Show() | |||
end<br> | |||
end | end | ||
eCoordinates:SetSize(100, 50) | eCoordinates:SetSize(100, 50) | ||
| Line 151: | Line 124: | ||
-- NO CHANGES. Just a copy and paste from above for your convenience while reading so that you don;t have to scroll up as much | -- NO CHANGES. Just a copy and paste from above for your convenience while reading so that you don;t have to scroll up as much | ||
local zone = nil | local zone = nil | ||
local TimeSinceLastUpdate = 0<br> | local TimeSinceLastUpdate = 0<br> | ||
local function UpdateCoordinates(self, elapsed) | local function UpdateCoordinates(self, elapsed) | ||
if zone ~= GetRealZoneText() then<br> zone = GetRealZoneText()<br> SetMapToCurrentZone()<br> end<br> | |||
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed<br> | |||
if TimeSinceLastUpdate > .5 then <br> TimeSinceLastUpdate = 0<br> local posX, posY = GetPlayerMapPosition("player"); <br> local x = math.floor(posX * 10000)/100<br> local y = math.floor(posY*10000)/100<br> eCoordinatesFontString:SetText("|c98FB98ff("..x..", "..y..")") <br> | |||
end | |||
if TimeSinceLastUpdate > .5 then <br> | |||
end | |||
end | end | ||
| Line 198: | Line 162: | ||
local posX, posY = GetPlayerMapPosition("player"); | local posX, posY = GetPlayerMapPosition("player"); | ||
-- Call the Blizzard function, GetPlayerMapPosition("player"), that will return our x and y coordinate. | -- Call the Blizzard function, GetPlayerMapPosition("player"), that will return our x and y coordinate. | ||
local x = math.floor(posX * 10000)/100 | local x = math.floor(posX * 10000)/100 | ||
local y = math.floor(posY*10000)/100 | local y = math.floor(posY*10000)/100 | ||
-- The returned values will be between 0 and 1. A little math allows an arbitrary number, say.7865 into 78.65, for both the x and y values. | -- The returned values will be between 0 and 1. A little math allows an arbitrary number, say.7865 into 78.65, for both the x and y values. | ||