PDA

View Full Version : How to access the party info now available?


KRc
10-02-2011, 08:25 PM
I can't seem to get a list of party members in a fellowship. I can get the number of members and info about the leader (such as the name), but nothing about the non-leader members of the group. How does it work?

It's driving me crazy. :confused:

Is there any place where the new RoI lua been documented?

Garan
10-02-2011, 10:13 PM
Once you get the Party, you simply call GetMember() to get a PartyMember object which has the same methods as the Player object:
GetName()
RegisterForClickHandling()
GetBaseMaxMorale()
GetBaseMaxPower()
GetEffects()
GetLevel()
GetMaxMorale()
GetMaxPower()
GetMorale()
GetPower()
GetAlignment()
GetClass()
GetParty()
GetRace()
GetReadyState()
IsLinkDead()
IsVoiceEnabled()

for example, the routine below will list the party member names and class codes.

local localPlayer=Turbine.Gameplay.LocalPlayer:GetInstan ce();
local party=localPlayer:GetParty();
if party~=nil then
local memberIndex, member;
for memberIndex=1,party:GetMemberCount() do
member=party:GetMember(memberIndex);
Turbine.Shell.WriteLine("Member("..memberIndex..") Name:"..member:GetName().." Class:"..member:GetClass())
end
end

MrJackdaw
10-03-2011, 12:37 AM
I didn't know you could get the effects on the party - this makes a huge difference. Buff helpers could now be a clear reality, with a whole heap of effort that is. Can you also register for when a party members buffs change?

Garan
10-03-2011, 07:29 AM
I didn't know you could get the effects on the party - this makes a huge difference. Buff helpers could now be a clear reality, with a whole heap of effort that is. Can you also register for when a party members buffs change?

I haven't played with the Party stuff at all yet. I imagine that since the PartyMember has the same exact Methods as Player, it is probably an extension of Player, so it probably inherits the same Event handlers.

EDIT: I did get to test it with PowerChanged() and the event fired properly (each member had to have a separate event handler). I'm not sure how you would go about managing adding and removing the event handlers unless there is a Party:MemberJoined() event or something. Unfortunately, possible Events are a lot harder to locate than Methods - Lua provides the names of the Methods in each objects' metatable.

KRc
10-03-2011, 08:20 AM
Thank you so much! I'd gone so far down meandering roads I doubt I could have come back to anything so simple by myself. What a relief.

*Wipes brow and gets on with things.*

Garan
10-03-2011, 08:44 AM
Thank you so much! I'd gone so far down meandering roads I doubt I could have come back to anything so simple by myself. What a relief.

*Wipes brow and gets on with things.*

PS though, a little typo in your example: you need to change tmpIndex to memberIndex in the line:

Turbine.Shell.WriteLine("Member(".. tmpIndex ..") Name:"..member:GetName().." Class:"..member:GetClass())

Regardless, it worked great.
Thanks for catching the typo. It's a pain copying and pasting from my Interactive Debug window so I got lazy and retyped it.

I accidentally made a slightly misleading statement earlier, while PartyMember has the same methods as Player, it isn't because it inherits from Player, more likely it inherits from Actor. If you want to see the Methods and Events that are likely available on the PartyMember, you should probably look at the Actor object in the Turbine Lua API docs.

MrJackdaw
10-03-2011, 09:14 AM
*Avoids temptation to start working on yet another plugin*

Damn you Garan, for giving me this info... *AGH!*

:)
.
.
.
*Still tempted*

Garan
10-03-2011, 10:36 AM
*Avoids temptation to start working on yet another plugin*

Damn you Garan, for giving me this info... *AGH!*

:)
.
.
.
*Still tempted*
LOL :) Yeah, I know. I am suffering from Potential Plugin Syndrome (PPS) myself. So MANY possibilities, so little time. Despite the fact that I was disappointed that we can't equip items programatically, I am sort of relieved since it allowed me to put at least one of those many, many ideas back on the back burner.

KRc
10-03-2011, 12:08 PM
*Still tempted*


You knew it was there...you know you want it... The party member stats — they taunt you!

:D

Pengoros
10-03-2011, 02:25 PM
I've been waiting on the docs to see if there is an event for party member joined/left. Otherwise the only alternative is to poll the fellowship every so often which seems suboptimal.

moebius92
10-03-2011, 07:02 PM
There's a PartyChanged event that occurs when you join a party, and presumably any time the party changes.

Garan
10-03-2011, 09:40 PM
The events seem to be:
LeaderChanged()
MemberAdded()
MemberRemoved()
AssistTargetAdded()
AssistTargetRemoved()
PartyChanged()
RaidChanged()

I may have missed some, but those seem to be valid. It's hard to test right now since my third gaming box spewed smoke and died and party changes usually require three characters to test.

Pengoros
10-04-2011, 02:23 PM
What is the difference between MemberAdded/Removed and Party/RaidChanged?

Also do you know what info is sent with each event? Guess I can just dump the event objects by doing some testing of the events :).

Having PartyChanged fire every time a member is added or removed seems redundant. I would guess it just fires every time you join or leave a fellowship?

Lycius
10-04-2011, 04:01 PM
What is the difference between MemberAdded/Removed and Party/RaidChanged?

Also do you know what info is sent with each event? Guess I can just dump the event objects by doing some testing of the events :).

Having PartyChanged fire every time a member is added or removed seems redundant. I would guess it just fires every time you join or leave a fellowship?

One thing to keep in mind is that there used to be a GetRaid() and GetParty() method, but GetRaid() was ditched due to redundancy. It's possible that there's a similar case here in the PartyChanged() and RaidChanged() events.

As for the differences between those and the MemberAdded()/MemberRemoved events, it could be that re-ordering the party members would trigger PartyChanged(), but wouldn't trigger the Added/Removed events. I could see that being a useful distinction to make.

Pengoros
10-04-2011, 05:06 PM
Out of the three events I was interested in(MemberAdded, MemberRemoved, PartyChanged) the only event I could get to fire was PartyChanged, none of the other events seem to work. I tested this with a group of 3.

moebius92
10-04-2011, 05:44 PM
Got a bit of a chance to play around with this - tested the following member events:

MoraleChanged, MaxMoraleChanged, BaseMaxMoraleChanged all seem to work (at least I think they all work - I dump all of them to the same event handler).

PowerChanged, MaxPowerChanged, BaseMaxPowerChanged also seems to work (again I think they work - I'm using the same handler for all power events as well).

EffectAdded seems to work, but effects have a tendency to get re-added every so often. They may be removed as well, but I can't tell because EffectRemoved and EffectCleared never triggered. I was in a different zone than the players I was testing my script with, so that may be a factor. Also, the effects list is ... odd. The count doesn't seem to be consistent, or always right. It'll never be larger than it should be, but it sometimes won't be as large as it should be. So, unfortunately, polling probably isn't an answer.

InCombatChanged never seemed to trigger - not a big deal, I can just use the player's.

Edit: I should note that this is for party members other than the player. On the player, all of the events worked fine.

Further Edit: Garan didn't mention it, but it looks like MemberAdded and MemberRemoved are Party events. Presumably so are LeaderChanged, AssistTargetAdded, AssistTargetRemoved.

Pengoros
10-05-2011, 02:17 AM
Ok I tried MemberRemoved and MemberAdded on the party and they work... until I zone somewhere then they stop working.

Edit: It seems it may not be a zone issue so much as members being added and removed. I posted a thread in the current api issues forum so that the developers are aware of it.