GetClassAttributes() bug and work around
There is some bug with using "GetClassAttributes()", at least for the Champion class that I experimented with so far.
Plus I'll give a little info for people trying to use this facility as the documentation and examples are sparse or just nonexistent. Lets say you want to read your Champion's fervor you want to call "GetFervor()" from your script. Ref: http://www.lotrointerface.com/wiki/ChampionAttributes A way to get to the class interface up to the method is: Code:
Turbine.Gameplay.LocalPlayer.GetInstance():GetClassAttributes():GetFervor() Code:
.. I get a "Fervor: 0" fine (as I had none at the time). But somehow on this call the LOTRO Lua API now nulls out the "GetFervor" method. On the second try you will get a "..nil function.." error. Incidentally dumping out what "...:GetClassAttributes()" returns you will see it's a user data not a table. Meaning internally the API uses a meta method(s) to access the data. If I'm not mistaken this "vanishing method issue" is a bug. Just calling the method shouldn't make it disappear. I would post this on the official forum but I only have a free account currently and thus I can't post it. Someone else reading this with a paid account please do so it can be fixed. Now, the only way I could get it to work with out killing the method is to store a reference to "..:GetClassAttributes()" globally on startup. Then I can call "GetFervor()" from this reference at will without error. Example on init (from my "__init__.lua", or what ever initialization layer): Code:
-- Global ref for Avatar attributes Code:
.. Every time I call "GetFervor()" it's calling an accessor internally that reads the (updated) value. Now we can get to work adding class specific UI things like a custom "fevor" bar, and, or digit display, etc. Edit: Opps, please move me to a more appropriate topic. |
It may have to do with the GetInstance() function, rather than anything else - try assigning GetInstance() to a variable, and then use the variable to call GetClassAttributes(). See if that changes anything.
Granted, this is kinda a shot in the dark - but it seems possible. |
All times are GMT -5. The time now is 09:34 AM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI