Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup and refactor #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
127 changes: 51 additions & 76 deletions CaptureZoneInfo.lua
Original file line number Diff line number Diff line change
@@ -1,83 +1,58 @@
TorteMe = TorteMe or {}

-- Valid loadType = login, reload, zone
function TorteMe:CaptureZoneInfo(loadType)

if loadType == "login" or loadType == "reload" then
TorteMe.sv.Zone.zoneId = GetZoneId(GetUnitZoneIndex("player"))
TorteMe.sv.Zone.parentZoneId = GetParentZoneId(TorteMe.sv.Zone.zoneId)
TorteMe.sv.Zone.zoneName = GetZoneNameById(TorteMe.sv.Zone.zoneId)
TorteMe.sv.Zone.oldZoneId = 0
TorteMe.sv.Zone.oldParentZoneId = 0
TorteMe.sv.Zone.oldZoneName = "Unknown"
if loadType == "login" then
if TorteMe.sv.Zone.parentZoneId == 181 then
TorteMe:Log("Welcome To Cyrodiil! - " .. TorteMe.displayName .. " enabled.")
TorteMe:Notify("Welcome to Cyrodiil!")
TorteMe:Log("Cyrodiil Login Detected.", true, 5)
if TorteMe.sv.Zone.zoneId == 181 then
TorteMe:Log("Login -> " .. TorteMe.sv.Zone.zoneName, true, 25)
else
TorteMe:Log("Login -> " .. TorteMe.sv.Zone.zoneName .. " (Cyrodiil)", true, 25)
end
else
TorteMe:Log("Non-Cyrodiil Login Detected.", true, 5)
TorteMe:Log("Login -> " .. TorteMe.sv.Zone.zoneName, true, 20)
end
else
if TorteMe.sv.Zone.parentZoneId == 181 then
TorteMe:Log("Welcome To Cyrodiil! - " .. TorteMe.displayName .. " enabled.")
TorteMe:Notify("Welcome to Cyrodiil!")
TorteMe:Log("ReloadUI IN Cyrodiil.", true, 25)
if TorteMe.sv.Zone.zoneId == 181 then
TorteMe:Log("ReloadUI -> " .. TorteMe.sv.Zone.zoneName, true, 25)
else
TorteMe:Log("ReloadUI -> " .. TorteMe.sv.Zone.zoneName .. " (Cyrodiil)", true, 25)
end
else
TorteMe:Log("Non-Cyrodiil ReloadUI Detected.", true, 5)
TorteMe:Log("ReloadUI -> " .. TorteMe.sv.Zone.zoneName, true, 20)
end
end
else
TorteMe.sv.Zone.oldZoneId = TorteMe.sv.Zone.zoneId
TorteMe.sv.Zone.oldParentZoneId = TorteMe.sv.Zone.parentZoneId
TorteMe.sv.Zone.oldZoneName = TorteMe.sv.Zone.zoneName
TorteMe.sv.Zone.zoneId = GetZoneId(GetUnitZoneIndex("player"))
TorteMe.sv.Zone.parentZoneId = GetParentZoneId(TorteMe.sv.Zone.zoneId)
TorteMe.sv.Zone.zoneName = GetZoneNameById(TorteMe.sv.Zone.zoneId)
if TorteMe.sv.Zone.parentZoneId == 181 and TorteMe.sv.Zone.oldParentZoneId ~= 181 then
TorteMe:Log("Welcome To Cyrodiil! - " .. TorteMe.displayName .. " enabled.")
TorteMe:Notify("Welcome to Cyrodiil!")
TorteMe:Log("Zoned INTO Cyrodiil.", true, 5)
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName, true, 25)
elseif TorteMe.sv.Zone.parentZoneId == 181 and TorteMe.sv.Zone.oldParentZoneId == 181 then
TorteMe:Log("Zoned WITHIN Cyrodiil.", true, 5)
if TorteMe.sv.Zone.oldZoneId == 181 and TorteMe.sv.Zone.zoneId ~= 181 then
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName .. " (Cyrodiil)", true, 25)
elseif TorteMe.sv.Zone.oldZoneId ~= 181 and TorteMe.sv.Zone.zoneId == 181 then
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " (Cyrodiil) -> " .. TorteMe.sv.Zone.zoneName, true, 25)
else
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName, true, 25)
end
local loadTypeStr = ""
local zoneDirectionStrInCyro = ""
local zoneDirectionStrExitCyro = ""
local zoneDirectionStrEnterCyro = ""
local zoneDirectionStr = ""

elseif TorteMe.sv.Zone.parentZoneId ~= 181 and TorteMe.sv.Zone.oldParentZoneId == 181 then
TorteMe:Log("Left Cyrodiil! - " .. TorteMe.displayName .. " disabled.")
TorteMe:Notify("Left Cyrodiil!")
TorteMe:Log("Zoned OUT of Cyrodiil.", true, 5)
if TorteMe.sv.Zone.oldZoneId == 181 then
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName, true, 20)
elseif TorteMe.sv.Zone.oldZoneId ~=181 then
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. "(Cyrodiil) -> " .. TorteMe.sv.Zone.zoneName, true, 20)
end
if loadType == "login" or loadType == "reload" then
TorteMe.sv.Zone.oldZoneId = 0
TorteMe.sv.Zone.oldParentZoneId = 0
TorteMe.sv.Zone.oldZoneName = "Unknown"
TorteMe.sv.Zone.zoneId = GetZoneId(GetUnitZoneIndex("player"))
TorteMe.sv.Zone.parentZoneId = GetParentZoneId(TorteMe.sv.Zone.zoneId)
TorteMe.sv.Zone.zoneName = GetZoneNameById(TorteMe.sv.Zone.zoneId)
if loadType == "login" then
loadTypeStr = "Login"
elseif loadType == "reload" then
loadTypeStr = "ReloadUI"
end
elseif loadType == "zone" then
TorteMe.sv.Zone.oldZoneId = TorteMe.sv.Zone.zoneId
TorteMe.sv.Zone.oldParentZoneId = TorteMe.sv.Zone.parentZoneId
TorteMe.sv.Zone.oldZoneName = TorteMe.sv.Zone.zoneName
TorteMe.sv.Zone.zoneId = GetZoneId(GetUnitZoneIndex("player"))
TorteMe.sv.Zone.parentZoneId = GetParentZoneId(TorteMe.sv.Zone.zoneId)
TorteMe.sv.Zone.zoneName = GetZoneNameById(TorteMe.sv.Zone.zoneId)
loadTypeStr = "Zone Change"
end

else
TorteMe:Log("Non-Cyrodiil Zone Detected.", true, 5)
if TorteMe.sv.Zone.oldParentZoneId == 181 and TorteMe.sv.Zone.oldZoneId ~= 181 then
TorteMe:Log("Left Cyrodiil! - " .. TorteMe.displayName .. " disabled.")
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " (Cyrodiil) -> " .. TorteMe.sv.Zone.zoneName, true, 20)
else
TorteMe:Log(TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName, true, 20)
end
end
end
zoneDirectionStrInCyro = TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName
zoneDirectionStrExitCyro = TorteMe.sv.Zone.oldZoneName .. " (Cyrodiil) -> " .. TorteMe.sv.Zone.zoneName
zoneDirectionStrEnterCyro = TorteMe.sv.Zone.oldZoneName .. " -> " .. TorteMe.sv.Zone.zoneName.." (Cyrodiil) "

TorteMe:Log("oldParentZoneId "..TorteMe.sv.Zone.oldParentZoneId.." newParentZoneId "..TorteMe.sv.Zone.parentZoneId, true, 25)

if TorteMe.sv.Zone.parentZoneId == TorteMe.const.ZONEID_CYRODIIL and TorteMe.sv.Zone.oldParentZoneId ~= TorteMe.const.ZONEID_CYRODIIL then
TorteMe:Log("Welcome To Cyrodiil! - " .. TorteMe.displayName .. " enabled.")
TorteMe:Notify("Welcome to Cyrodiil!")
zoneDirectionStr = zoneDirectionStrEnterCyro
elseif TorteMe.sv.Zone.parentZoneId ~= TorteMe.const.ZONEID_CYRODIIL and TorteMe.sv.Zone.oldParentZoneId == TorteMe.const.ZONEID_CYRODIIL then
TorteMe:Log("Left Cyrodiil! - " .. TorteMe.displayName .. " disabled.")
TorteMe:Notify("Left Cyrodiil!")
zoneDirectionStr = zoneDirectionStrExitCyro
elseif TorteMe.sv.Zone.parentZoneId == TorteMe.const.ZONEID_CYRODIIL and TorteMe.sv.Zone.oldParentZoneId == TorteMe.const.ZONEID_CYRODIIL then
TorteMe:Log("Movement in Cyrodiil - " .. TorteMe.displayName .. " enabled.")
TorteMe:Notify("Scene Change in Cyrodiil")
zoneDirectionStr = zoneDirectionStrInCyro
end

if TorteMe.sv.Zone.parentZoneId == TorteMe.const.ZONEID_CYRODIIL or TorteMe.sv.Zone.oldParentZoneId == TorteMe.const.ZONEID_CYRODIIL then
TorteMe:Log(loadTypeStr.." Detected.", true, 25)
TorteMe:Log(zoneDirectionStr, true, 20)
end
end
Loading