ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   CP 2.0 Error (https://www.esoui.com/forums/showthread.php?t=9645)

ownedbynico 03/21/21 09:36 AM

CP 2.0 Error
 
Hey,

I'm currently working on a CP 2.0 Addon. Every time I load the CPs it's working fine untill the point where I open the CP Scene and get the following error:

Code:

EsoUI/Ingame/Champion/Champion.lua:2285: attempt to index a nil value
stack traceback:
EsoUI/Ingame/Champion/Champion.lua:2285: in function 'ChampionPerks:OnUpdate'
<Locals> self = [table:1]{keybindState = 1, cameraRootY = 800, constellationOuterRadius = 528, cameraPanZ = 0, constellationInnerRadius = 190, keybindStripId = 2, isChampionSystemNew = F, cameraAnimationOffsetX = 0, startCameraZ = -1, cameraAnimationOffsetZ = 0, isInRespecMode = F, constellationsInitialized = T, startCameraY = 800, cameraPanY = 0, confirmAnimationPlaying = T, firstStarConfirm = F, awaitingSpendPointsResponse = F, startAngle = 2.6179938779915, cameraRootX = 0, startCameraX = -0, constellationHeight = 338, t = 0.010000400000081, lastHealthValue = 20002, cameraAnimationOffsetY = 0, initialized = T, cameraPanX = 0, nextConfirmAnimationTime = 4010.8349121094, cameraRootZ = -1}, timeSecs = 4010.5349121094, frameDeltaSecs = 0.010000400000081, isEnteringConstellation = F </Locals>
EsoUI/Ingame/Champion/Champion.lua:1170: in function '(anonymous)'
<Locals> _ = ud, timeSecs = 4010.5349121094 </Locals>


I don't really know if the mistake is on my part, since I do exactly the same thing as other addons. :confused:
The loading code is the following:

Code:

for slotIndex = 1, 12 do
  if cptable[setId][slotIndex] ~= nil then
    AddHotbarSlotToChampionPurchaseRequest(slotIndex, cptable[setId][slotIndex])
  end
end
SendChampionPurchaseRequest()

Yes, I'm aware of the cooldown in between. The addon does wait 30s in between the changes.

Has anyone seen the error before and can help me?
Thanks in advance.

Sharlikran 03/21/21 10:03 AM

Warning: Spoiler

Ooops I didn't see that the error was from the Zos code itself and not your code. You have done something to cause an error in the ZOS code. I do not know the CP system at all. Sorry for posting.

ownedbynico 03/21/21 10:07 AM

Quote:

Originally Posted by Sharlikran (Post 43523)
Which line is 2285? If it is "if cptable[setId][slotIndex] ~= nil then" then the table does not have the values at the time it is looked at. So while you are saying "~= nil" the table, setId, and slotIndex need to be defined.

if cptable[setId] == nil then cptable[setId] = {} end
if cptable[setId][slotIndex] == nil then cptable[setId][slotIndex] = {} end

The table will be empty and not nil.

However, I don't think you can have cptable[setId][slotIndex] = nil, if I understand correctly because nil is not important so it would just be cptable[setId] = <<whatever>>

Champion.lua is not my code, it's from the Api. And the table cptable cannot be empty at this point.
https://github.com/esoui/esoui/blob/...pion.lua#L2285
It's a function for CP animations.

Sharlikran 03/21/21 10:13 AM

Yeah sorry, I posted my correction before you saw it and replied. Sorry for posting.

Baertram 03/21/21 10:16 AM

Seems like self.confirmCameraPrepTimeline is nil / was not initialized via function https://github.com/esoui/esoui/blob/...pion.lua#L1581 properly before then
Do you try to open the CP scene via addon code or manually (keybnd/menu click)?
Maybe you try to open it wrong like SCENE_MANAGER:ShowScene .... (if even able per addon!) and thus the stuff is not initialized properly

ownedbynico 03/21/21 10:19 AM

Quote:

Originally Posted by Baertram (Post 43526)
Seems like self.confirmCameraPrepTimeline is nil / was not initialized via function https://github.com/esoui/esoui/blob/...pion.lua#L1581 properly before then
Do you try to open the CP scene via addon code or manually (keybnd/menu click)?
Maybe you try to open it wrong like SCENE_MANAGER:ShowScene .... (if even able per addon!) and thus the stuff is not initialized properly

Gitter is a bit slow atm so I'll answer here.

I let the addon set the CP and after that I open the CP scene by hand with the keybind.
Is there any way of getting access to the ChampionPerks Object? It's created locally, so I'm not really sure if that is possible.

Baertram 03/21/21 11:00 AM

No afaik Champion and Crown Store stuff is by design local so no addon can interfere there.

Maybe you code to switch the CPs is somehow changing some UI stuff and as the scene is shown the UI stuff thinks all is ready, but it isn't.
Have a look at Caro's Skill and CP Point manager, or other CP related addons how they do the same. Perhaps you'll find your error/code lines which cause it this way.

Irniben 03/21/21 11:25 AM

Hey, I had the same problem with CSPS. I used the following code before sending the purchase request to prevent the game from trying to play a confirm animation while not in the perks scene and do the needed preparation for it if the scene is shown:

Code:

       
if CHAMPION_PERKS_SCENE:GetState() == "shown" then
        CHAMPION_PERKS:PrepareStarConfirmAnimation()
        cancelAnimation = false
else
        cancelAnimation = true
end
ZO_PreHook(CHAMPION_PERKS, "StartStarConfirmAnimation",
        function()
                if cancelAnimation then
                        cancelAnimation = false
                        return true
                end
        end)


ownedbynico 03/22/21 06:56 AM

Quote:

Originally Posted by Irniben (Post 43530)
Hey, I had the same problem with CSPS. I used the following code before sending the purchase request to prevent the game from trying to play a confirm animation while not in the perks scene and do the needed preparation for it if the scene is shown:

Code:

       
if CHAMPION_PERKS_SCENE:GetState() == "shown" then
        CHAMPION_PERKS:PrepareStarConfirmAnimation()
        cancelAnimation = false
else
        cancelAnimation = true
end
ZO_PreHook(CHAMPION_PERKS, "StartStarConfirmAnimation",
        function()
                if cancelAnimation then
                        cancelAnimation = false
                        return true
                end
        end)


Thanks! That fixes the problem.
So there is actually a way to get the ChampionPerks stuff.

Irniben 03/22/21 11:09 AM

Quote:

Originally Posted by ownedbynico (Post 43538)
Thanks! That fixes the problem.
So there is actually a way to get the ChampionPerks stuff.

Just noted another thing: in the code you quoted there is no "PrepareChampionPurchaseRequest()". I'm not really sure about everything that function does, but as far as I found out it resets the purchase, if anything else added skills to that before you - so it should be called before building your purchase request I guess.


All times are GMT -6. The time now is 03:11 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI