LUA Error then... i dont know, it's random
fubaWoW opened this issue ยท 1 comments
LUA Error
2x PetTracker/addons/main/features/tooltips.lua:22: attempt to index a nil value
[string "@PetTracker/addons/main/features/tooltips.lua"]:22: in function <PetTracker/addons/main/features/tooltips.lua:14>
[string "=(tail call)"]: ?
[string "=[C]"]: in function `securecallfunction'
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:61: in function <...lizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua:56>
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:81: in function <...lizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua:77>
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:117: in function <...lizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua:107>
[string "=[C]"]: in function `SetAttribute'
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:142: in function <...lizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua:135>
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:288: in function <...lizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua:238>
[string "=[C]"]: in function `securecallfunction'
[string "@Blizzard_SharedXMLGame/Tooltip/TooltipDataHandler.lua"]:235: in function `ProcessInfo'
[string "@Blizzard_GameTooltip/Mainline/GameTooltip.lua"]:942: in function `SetWorldCursor'
[string "@Blizzard_UIParent/Mainline/UIParent.lua"]:1370: in function <...rfaceBlizzard_UIParent/Mainline/UIParent.lua:1293>
[string "=[C]"]: ?
Locals:
tip = GameTooltip {
ItemTooltip = Frame {
}
shadow = Frame {
}
BottomOverlay = Texture {
}
NineSlice = Frame {
}
textLeft1Font = "GameTooltipHeaderText"
hasMoney = 1
textRight2Font = "GameTooltipText"
windInspectLoaded = false
TopOverlay = Texture {
}
TextLeft1 = GameTooltipTextLeft1 {
}
StatusBar = GameTooltipStatusBar {
}
__windShadow = 1
ARKTTD = <table> {
}
numMoneyFrames = 2
PixelSnapDisabled = true
supportsDataRefresh = true
CIMI_tooltipWritten = false
petIcon = Texture {
}
processingInfo = <table> {
}
infoList = <table> {
}
waitingForData = false
shoppingTooltips = <table> {
}
updateTooltipTimer = 0.109000
TextRight1 = GameTooltipTextRight1 {
}
supportsItemComparison = true
textRight1Font = "GameTooltipHeaderText"
layoutType = "TooltipDefaultLayout"
textLeft2Font = "GameTooltipText"
TextRight2 = GameTooltipTextRight2 {
}
TextLeft2 = GameTooltipTextLeft2 {
}
}
name = "Hermit Crab"
specie = 2399
owned = "Collected: |TAddons/PetTracker/art/breeds:12:17:-2:0:64:64:40:64:22:39|t|cff0070dd25|r |TAddons/PetTracker/art/breeds:12:17:-2:0:64:64:40:64:22:39|t|cff0070dd25|r |TAddons/PetTracker/art/breeds:12:17:-2:0:64:64:40:64:22:39|t|cff0070dd25|r"
(for index) = 3
(for limit) = 4
(for step) = 1
i = 3
line = GameTooltipTextLeft3 {
}
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = 4
(*temporary) = "attempt to index a nil value"
Addon = <table> {
Enemy = <table> {
}
JournalMods = <table> {
}
Species = <table> {
}
Rival = <table> {
}
Tracker = <table> {
}
RivalInfo = <table> {
}
MultiTip = <table> {
}
MaxQuality = 6
Rivals = <table> {
}
Base = <table> {
}
SpecieBreeds = <table> {
}
TrackToggle = PetTrackerTrackToggle {
}
AbilityButton = <table> {
}
Name = "PetTracker"
BattleSlot = <table> {
}
Objectives = Frame {
}
SpeciePin = <table> {
}
MaxLevel = 25
RivalPin = <table> {
}
Entity = <table> {
}
RivalOrder = <table> {
}
JournalSlot = <table> {
}
StablePin = <table> {
}
AbilityDisplay = <table> {
}
Breeds = <table> {
}
Pin = <table> {
}
Tag = "PetTracker."
MapCanvas = <table> {
}
ProgressBar = <table> {
}
SpecieStats = <table> {
}
PetSlot = <table> {
}
RivalsJournal = PetTrackerRivalsJournal {
}
sets = <table> {
}
state = <table> {
}
Stables = <table> {
}
Maps = <table> {
}
AbilityAction = <table> {
}
BattleRecord = <table> {
}
Pet = <table> {
}
Tooltips = <table> {
}
Predict = <table> {
}
MaxPlayerQuality = 4
SpecieLine = <table> {
}
Specie = <table> {
}
Ability = <table> {
}
}
a "simple" fix would be...
in the file tooltips.lua
at line 22, replace:
if line:GetText():find('^' .. COLLECTED) then
with this one
if line and line:GetText() ~= nil and line:GetText():find('^' .. COLLECTED) then
but it is just an "imperfect" fix!
a "proper" way would be to replace the whole function function Tooltips.OnUnit(tip)
with this:
function Tooltips.OnUnit(tip)
if not tip or not TooltipUtil.GetDisplayedUnit then return end
local name = TooltipUtil.GetDisplayedUnit(tip)
if not name or not C_PetJournal.FindPetIDByName then return end
local specie = C_PetJournal.FindPetIDByName(name)
if not specie or not Addon.Specie then return end
local specieObj = Addon.Specie(specie)
if not specieObj or not specieObj.GetOwnedText then return end
local owned = specieObj:GetOwnedText()
if not owned or not tip.NumLines or not tip.GetName then return end
for i = 1, tip:NumLines() do
local lineName = tip:GetName() .. 'TextLeft' .. i
local line = lineName and _G[lineName]
if line and line.GetText and line.SetText then
local text = line:GetText()
if text and text:find('^' .. COLLECTED) then
line:SetText(DIM_GREEN_FONT_COLOR:WrapTextInColorCode(owned))
return
end
end
end
end
to prevent ALL possible NIL errors...
this also should be done with every function that "can" throw nil errors!
for example function Tooltips.OnBattlePet(tip, data)
should be replaced with this:
function Tooltips.OnBattlePet(tip, data)
if not tip or not data or not data.speciesID then return end
local specie = Addon.Specie and Addon.Specie(data.speciesID)
local breed = Addon.Predict and Addon.Predict.Breed and Addon.Predict:Breed(
data.speciesID, data.level, (data.breedQuality or 0) + 1, data.maxHealth, data.power, data.speed
)
if not specie or not breed then return end
tip.specie = specie
tip.breed = breed
if not tip.Source then
if not tip.CreateFontString then return end
tip.Source = tip:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightLeft')
tip.Source:SetPoint('BOTTOMLEFT', tip, 11, 8)
tip.Source:SetSize((tip.GetWidth and tip:GetWidth() or 0) - 20, 0)
hooksecurefunc(tip, 'Show', function(t)
if not t or not t.specie or not t.breed then return end
if t.Owned and t.Owned.SetText then
t.Owned:SetText(NORMAL_FONT_COLOR:WrapTextInColorCode(t.specie:GetOwnedText() or ''))
end
if t.Name and t.Name.SetText then
t.Name:SetText((t.Name:GetText() or '') .. Addon.Breeds:Icon(t.breed, .8, 5, 0))
end
if t.Source and t.Source.SetText then
t.Source:SetText(select(5, t.specie:GetInfo()) or '')
end
if t.SetHeight and t.GetHeight and t.Source.GetHeight then
t:SetHeight(t:GetHeight() + t.Source:GetHeight())
end
end)
end
end
but it's up to you, just suggesting ^^
greetings