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

LUA Error then... i dont know, it's random #427

Open
fubaWoW opened this issue Nov 30, 2024 · 3 comments
Open

LUA Error then... i dont know, it's random #427

fubaWoW opened this issue Nov 30, 2024 · 3 comments

Comments

@fubaWoW
Copy link

fubaWoW commented Nov 30, 2024

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> {
 }
}
@fubaWoW
Copy link
Author

fubaWoW commented Dec 4, 2024

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

@Haembina
Copy link

I got the same error too

4x 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"]:953: in function `SetWorldCursor'
[string "@Blizzard_UIParent/Mainline/UIParent.lua"]:1368: in function <...rfaceBlizzard_UIParent/Mainline/UIParent.lua:1291>

Locals:
tip = GameTooltip {
 ItemTooltip = Frame {
 }
 AllTheThingsOnTooltipClearedHook = true
 BottomOverlay = Texture {
 }
 NineSlice = Frame {
 }
 EltruismTooltipHook = true
 textLeft1Font = "GameTooltipHeaderText"
 hasMoney = 1
 textRight2Font = "GameTooltipText"
 windInspectLoaded = false
 TopOverlay = Texture {
 }
 TextLeft1 = GameTooltipTextLeft1 {
 }
 processingInfo = <table> {
 }
 infoList = <table> {
 }
 StatusBar = GameTooltipStatusBar {
 }
 statusBarPool = <table> {
 }
 numMoneyFrames = 2
 PixelSnapDisabled = true
 shouldRefreshData = false
 supportsDataRefresh = true
 CIMI_tooltipWritten = false
 factionFrame = Texture {
 }
 petIcon = Texture {
 }
 waitingForData = false
 style = Frame {
 }
 shoppingTooltips = <table> {
 }
 progressBarPool = <table> {
 }
 updateTooltipTimer = 0.002000
 TextRight1 = GameTooltipTextRight1 {
 }
 supportsItemComparison = true
 textRight1Font = "GameTooltipHeaderText"
 layoutType = "TooltipDefaultLayout"
 textLeft2Font = "GameTooltipText"
 TextRight2 = GameTooltipTextRight2 {
 }
 TextLeft2 = GameTooltipTextLeft2 {
 }
}
name = "Shore Crab"
specie = 388
owned = "Collected:  |TPetBattles/PetBattle-StatIcons:17:17:-2:0:32:32:16:32:0:16|t|cff9d9d9d3|r"
(for index) = 3
(for limit) = 3
(for step) = 1
i = 3
line = GameTooltipTextLeft3 {
}
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = 2
(*temporary) = "attempt to index a nil value"
Addon = <table> {
 Switcher = PetTrackerSwitcher {
 }
 Enemy = <table> {
 }
 JournalMods = <table> {
 }
 Species = <table> {
 }
 Rival = <table> {
 }
 Tracker = <table> {
 }
 RivalInfo = <table> {
 }
 MultiTip = <table> {
 }
 BattleListener = <table> {
 }
 MaxQuality = 6
 Battle = <table> {
 }
 EnemyBar = Frame {
 }
 Rivals = <table> {
 }
 Base = <table> {
 }
 SpecieBreeds = <table> {
 }
 TrackToggle = PetTrackerTrackToggle {
 }
 AbilityButton = <table> {
 }
 Name = "PetTracker"
 BattleSlot = <table> {
 }
 Objectives = Frame {
 }
 SpeciePin = <table> {
 }
 Alerts = Sushi-3.2-Glowbox1 {
 }
 MaxLevel = 25
 RivalPin = <table> {
 }
 Entity = <table> {
 }
 RivalOrder = <table> {
 }
 JournalSlot = <table> {
 }
 StablePin = <table> {
 }
 Units = <table> {
 }
 AbilityDisplay = <table> {
 }
 Breeds = <table> {
 }
 Pin = <table> {
 }
 Tag = "PetTracker."
 MapCanvas = <table> {
 }
 ProgressBar = <table> {
 }
 SpecieStats = <table> {
 }
 Tooltips = <table> {
 }
 Options = Frame {
 }
 PetSlot = <table> {
 }
 RivalsJournal = PetTrackerRivalsJournal {
 }
 sets = <table> {
 }
 state = <table> {
 }
 Stables = <table> {
 }
 Maps = <table> {
 }
 AbilityAction = <table> {
 }
 BattleRecord = <table> {
 }
 Pet = <table> {
 }
 Tutorials = <table> {
 }
 Predict = <table> {
 }
 MaxPlayerQuality = 4
 SpecieLine = <table> {
 }
 Specie = <table> {
 }
 Ability = <table> {
 }
}

@skupfer
Copy link

skupfer commented Dec 30, 2024

When hovering/targeting Father Winter's Helper, i.e. in Orgrimmar (the quick flight dude)

EDIT: Random spider critter in raid nerub-ar palace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants