Thread Tools Display Modes
03/21/21, 09:36 AM   #1
ownedbynico
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 9
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.
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.

Last edited by ownedbynico : 03/21/21 at 09:50 AM.
  Reply With Quote
03/21/21, 10:03 AM   #2
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
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.

Last edited by Sharlikran : 03/21/21 at 10:07 AM.
  Reply With Quote
03/21/21, 10:07 AM   #3
ownedbynico
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 9
Originally Posted by Sharlikran View Post
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.

Last edited by ownedbynico : 03/21/21 at 10:09 AM.
  Reply With Quote
03/21/21, 10:13 AM   #4
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Yeah sorry, I posted my correction before you saw it and replied. Sorry for posting.
  Reply With Quote
03/21/21, 10:16 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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
  Reply With Quote
03/21/21, 10:19 AM   #6
ownedbynico
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 9
Originally Posted by Baertram View Post
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.
  Reply With Quote
03/21/21, 11:00 AM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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.
  Reply With Quote
03/21/21, 11:25 AM   #8
Irniben
 
Irniben's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2021
Posts: 6
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)
  Reply With Quote
03/22/21, 06:56 AM   #9
ownedbynico
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 9
Originally Posted by Irniben View Post
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.

Last edited by ownedbynico : 03/22/21 at 07:08 AM.
  Reply With Quote
03/22/21, 11:09 AM   #10
Irniben
 
Irniben's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2021
Posts: 6
Originally Posted by ownedbynico View Post
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.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » CP 2.0 Error

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off