Thread Tools Display Modes
07/18/15, 08:41 AM   #1
SmashingQuasar
Join Date: Jul 2015
Posts: 7
SetMovable() function and userdata class

Hey everybody,

So my friend and I are currently working on an addon to vastly improve ESO's character sheet.

We found out that the character sheet object is: ZO_StatsPanel
It has for parent GuiRoot (well basically, the game window), problem is, I tried to use the method SetMovable() on ZO_StatsPanel (ZO_StatsPanel.SetMovable(true)) but it created an error stating SetMovable() expects the parameter to be of userdata type, not boolean. When I read the extremely sparse API documentation, I found the SetMovable() function, which expects the parameter to be boolean.

So I'd like to know what is the userdata class? (I assume it's an object class)
I'd also like to understand how to use this method on this panel.

Thanks a lot
  Reply With Quote
07/18/15, 08:49 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,589
You need to call it like this:
Lua Code:
  1. ZO_StatsPanel:SetMovable(true)
which is the same as this:
Lua Code:
  1. ZO_StatsPanel.SetMovable(ZO_StatsPanel, true)
  Reply With Quote
07/18/15, 08:56 AM   #3
SmashingQuasar
Join Date: Jul 2015
Posts: 7
Oh, I didn't know methods were called with : in lua :> Didn't even consider it in fact which is a shame xD

Thanks a lot for your help, any idea why the background texture isn't moving with the window now that my code works?
  Reply With Quote
07/18/15, 09:40 AM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by SmashingQuasar View Post
Oh, I didn't know methods were called with : in lua :> Didn't even consider it in fact which is a shame xD

Thanks a lot for your help, any idea why the background texture isn't moving with the window now that my code works?
They don't "have" to be called with :
Using the : just tells it to pass the calling object as the first parameter, so if you use : and type this:
Lua Code:
  1. ZO_StatsPanel:SetMovable(true)
  2. -- the : really means it is going to pass
  3. -- these parameters: (ZO_StatsPanel, true)

As sirinsidiator said, you could also call
Lua Code:
  1. ZO_StatsPanel.SetMovable(ZO_StatsPanel, true)
Notice here the : is not used, but we manually type in the parameter ZO_StatsPanel as the first parameter.

As for your background, it is because that background (ZO_SharedStatsBackground) is not part of the window ZO_StatsPanel, its just a shared background that gets hidden/shown when its needed.

Last edited by circonian : 07/18/15 at 09:49 AM.
  Reply With Quote
07/18/15, 11:38 AM   #5
SmashingQuasar
Join Date: Jul 2015
Posts: 7
Thanks for your help, I managed to do a lot of things I wanted to, and it's starting to take shape, I've one more question while this thread is alive.

Is there a way to know when the player opens the character sheet (ZO_StatsPanel) ? My problem is: All the children do not exist when the character sheet isn't open, and thus preveting me from changing their position/hiding them.
  Reply With Quote
07/18/15, 03:19 PM   #6
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Here you go:

Lua Code:
  1. local function OnStateChange(oldState, newState)
  2.     if newState == SCENE_SHOWN then
  3.         -- its now visible, do whatever
  4.     end
  5. end
  6. STATS_SCENE:RegisterCallback("StateChange", OnStateChange)

Possible results for oldState & newState are:
Lua Code:
  1. SCENE_HIDING  -- (the scene is in the process of hiding, but not yet finished)
  2. SCENE_HIDDEN -- (the scene has finished hiding)
  3. SCENE_SHOWING -- (the scene is in the process of being shown, but not yet finished)
  4. SCENE_SHOWN -- (the scene has finished showing)
  Reply With Quote
07/20/15, 04:31 AM   #7
SmashingQuasar
Join Date: Jul 2015
Posts: 7
Thanks for your help, I totally reworked my code so the add-on does not process the modifications when loaded but only when the character sheet is opened. I have other questions but I think I'll open another thread since it's unrelated to my first question.

Thanks again guys, really saved my life
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » SetMovable() function and userdata class


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