I am calling an API function in the Lord of the Rings Online (LOTRO) Beta Lua scripting feature. The API method returns a “type” called ClassAttributes that will be on of the given Class Attribute “types”. I say “types” because when I call type() on the return value, it says its a table.
Is there a way for me to check the type, or metatable type? e.g.:
local returnedTable = player:GetClassAttributes();
if (returnedTable.Name == "CaptainClassAttributes")
print("You are playing a captain");
end
UPDATE
The following code is what I use:
player = Turbine.Gameplay.LocalPlayer.GetInstance();
Turbine.Shell.WriteLine("player:GetClass():" .. player:GetClass());
Turbine.Shell.WriteLine("Turbine.Gameplay.Class.Captain:" .. Turbine.Gameplay.Class.Captain);
if (player:GetClass() == Turbine.Gameplay.Class.Captain) then
Turbine.Shell.WriteLine("You are playing a captain");
end
and here is the output:
player:GetClass():24
Turbine.Gameplay.Class.Captain:24
You are playing a captain
The API docs are a bit confusing, although I suppose I found what you’re looking for.
The following code should tell you if player is a Captain:
Captain is a member of the Gameplay.Class table, which is just an integer number as reading from the docs.
Note: You don’t need to end a Lua sentence with a “;”.
Couldn’t test it. Hope it works.