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.
A way to get to the class interface up to the method is:
In a minimal test setup registered a "/test" command as such:
print = Turbine.Shell.WriteLine
-- Register "/test"
ShellCommand = Turbine.ShellCommand()
function ShellCommand:Execute(command, arguments)
Now when loaded and then "/test" the first time all is well.
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):
-- Global ref for Avatar attributes
AvatarAttributes = Turbine.Gameplay.LocalPlayer.GetInstance():GetClassAttributes()
Now from my "Execute" I can "/test" without issue:
function iff(cond, A, B) if cond then return A else return B end end
print("IsIEDR: "..iff(AvatarAttributes:IsInEnemyDefeatResponse(), "true", "false"))
FYI: Of how LOTRO's Lua internals work data like fevor gets updated as needed (it's not a Lua type copy).
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.