GetClassAttributes() bug and work around - LoTROInterface
Search Downloads

Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Thread Tools Display Modes
Unread 06-19-2011, 12:23 AM
Sargatanis Sargatanis is offline
The Wary
Join Date: Jun 2011
Posts: 1
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:
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)
   print("Fervor: "..Turbine.Gameplay.LocalPlayer.GetInstance():GetClassAttributes():GetFervor())
function ShellCommand:GetHelp()
function ShellCommand:GetShortHelp()
Turbine.Shell.AddCommand("test", ShellCommand)
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("Fervor: "..AvatarAttributes:GetFervor())
print("Stance: "..AvatarAttributes:GetStance())
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.

Last edited by Sargatanis : 06-19-2011 at 12:45 AM.
Reply With Quote
Unread 06-19-2011, 02:06 AM
Digital_Utopia's Avatar
Digital_Utopia Digital_Utopia is offline
The Undying
Interface Author - Click to view interfaces
Join Date: Sep 2010
Posts: 207
Send a message via MSN to Digital_Utopia Send a message via Yahoo to Digital_Utopia
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.

Lord of the Rings Online
75 Fourohfour | 75 Artemedis | 60 Whiskeytango Foxtrot | 50 Mistah Boombastic | 56 Appetizer | 25 Aggromi
61 Onepointtwentyone Gigawatts

World of Warcraft
90 Downlo 85 Gravetaxi 85 Ümad 85 Artemedis 85 Guthuros
Reply With Quote

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble getting plugins to work dtsalmon Interface Help (L) 7 01-31-2011 07:51 AM
Turbine lotro bug of quickslot Bar 3, anyone else notice it? Bachihihii Interface Help (L) 3 02-01-2010 09:01 AM
Please help a noob with some detective work. GCT General Authoring Discussion (L) 0 12-04-2008 01:32 PM
Download Reporting Bug? AncientWolf Site help, bugs, suggestions/questions 2 07-30-2007 11:46 AM
Ok Devs! What do we have to work with? AncientWolf Preview Server (L) 3 07-10-2007 09:02 AM

All times are GMT -5. The time now is 02:20 AM.

Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui