Created
May 1, 2020 08:04
-
-
Save addohm/aaa67fc11f18bba97f611c8167f18129 to your computer and use it in GitHub Desktop.
Layer Checker Simplified
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local LayerChecker = CreateFrame'Frame' | |
local layer_id = nil | |
LayerChecker:SetScript('OnUpdate', function() LayerChecker:UPDATE() end) | |
LayerChecker:SetScript('OnEvent', function(_, event, arg1, arg2) | |
if event == 'ADDON_LOADED' and arg1 == 'LayerChecker' then | |
if LCDB == nil then | |
LCDB = {} | |
LayerChecker_Frame:Show() | |
end | |
if LCDB ~= nil then | |
if LCDB["visible"] == true then | |
LayerChecker_Frame:Show() | |
else | |
LayerChecker_Frame:Hide() | |
end | |
end | |
elseif event == 'ZONE_CHANGED_NEW_AREA' then | |
layer_id = nil | |
LayerCheckerUI_onUpdate() | |
elseif event == 'UPDATE_MOUSEOVER_UNIT' then | |
LayerChecker:onTarget() | |
elseif event == 'CHAT_MSG_WHISPER' then | |
LayerChecker:autoRespond(arg1, arg2) | |
elseif event == 'CHAT_MSG_LOOT' then | |
elseif event == 'CHAT_MSG_GUILD' then | |
LayerChecker:autoRespond(arg1, arg2, 'guild') | |
end | |
end) | |
function LayerCheckerUI_onUpdate() | |
LayerChecker_FrameTextA:SetText("Layer:"); | |
if layer_id ~= nil then | |
LayerChecker_FrameTextB:SetText(layer_id); | |
LayerChecker_FrameTextB:SetTextColor(1, 1, 1, 1) | |
LayerChecker_FrameTextA:SetTextColor(1, 1, 1, 1) | |
else | |
LayerChecker_FrameTextB:SetText("N/A"); | |
LayerChecker_FrameTextB:SetTextColor(1, 0, 0, 0.5) | |
LayerChecker_FrameTextA:SetTextColor(1, 1, 1, 0.5) | |
end | |
end | |
function LayerChecker:autoRespond(a, b, c) | |
local msg | |
local location = GetZoneText() | |
if c == "guild" then | |
local command, place = strsplit("-",a) | |
if command == "lc" then | |
if location == place then | |
DEFAULT_CHAT_FRAME:AddMessage("triggering guildcheck", 1.0, 1.0, 1.0); | |
if layer_id ~= nil then | |
msg = "In " .. location .. " layer ID " .. layer_id | |
SendChatMessage(msg, "WHISPER", nil, b); | |
end | |
end | |
end | |
end | |
if a == "layercheck" then | |
if layer_id ~= nil then | |
msg = "In " .. location .. " layer ID " .. layer_id | |
else | |
msg ="no layer ID" | |
end | |
SendChatMessage(msg, "WHISPER", nil, b); | |
end | |
end | |
function LayerChecker:onTarget() | |
local guid = UnitGUID("mouseover") | |
if guid ~= nil then | |
local type, zero, server_id, instance_id, zone_uid, npc_id, spawn_uid = strsplit("-",guid) | |
if type == "Creature" then | |
layer_id = math.ceil(zone_uid/100) | |
end | |
LayerCheckerUI_onUpdate() | |
end | |
end | |
function LayerChecker:UPDATE() | |
end | |
SLASH_LAYERCHECKER1, SLASH_LAYERCHECKER2 = '/lc', '/layerchecker' | |
function SlashCmdList.LAYERCHECKER(msg, editBox) | |
if msg == 'show' then | |
LayerChecker_Frame:Show() | |
LayerChecker_Frame:Show() | |
LCDB["visible"] = true | |
elseif msg == 'hide' then | |
LayerChecker_Frame:Hide() | |
LayerChecker_Frame:Hide() | |
LCDB["visible"] = false | |
else | |
DEFAULT_CHAT_FRAME:AddMessage(" ", 1.0, 1.0, 1.0); | |
DEFAULT_CHAT_FRAME:AddMessage("|cff3399FFLayerChecker|r by Odors of Stalagg. version 1.1", 1.0, 1.0, 1.0); | |
DEFAULT_CHAT_FRAME:AddMessage("|cff3399FF/lc show|r - show UI", 1.0, 1.0, 1.0); | |
DEFAULT_CHAT_FRAME:AddMessage("|cff3399FF/lc hide|r - hide UI", 1.0, 1.0, 1.0); | |
end | |
end | |
-- register event hooks | |
LayerChecker:RegisterEvent'ZONE_CHANGED_NEW_AREA' | |
LayerChecker:RegisterEvent'UPDATE_MOUSEOVER_UNIT' | |
LayerChecker:RegisterEvent'CHAT_MSG_WHISPER' | |
LayerChecker:RegisterEvent'CHAT_MSG_GUILD' | |
LayerChecker:RegisterEvent'CHAT_MSG_LOOT' | |
LayerChecker:RegisterEvent'ADDON_LOADED' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment