Jump to content
Sign in to follow this  
HazJ

[SOLVED] Return group from lbData

Recommended Posts

Hi all,

I am in the process of making my own group management but have come across an issue. I can't seem to get the group from lbData command. When I hint the data type it comes back as STRING instead of GROUP but when I do it with getVariable it shows fine. Here's a quick vidoe that I hope shows my problem:

// Create test (DUMMY) group
testGroup = createGroup blufor;
testGroup setGroupIdGlobal ["Test Group"];
// Add the heroic and awesome "Bov" to the group
Bov = testGroup createUnit ["B_RangeMaster_F", [0, 0, 0], [], 0, "FORM"];

// Add the above group data to the groups array
groups = [["Test Group", testGroup]];

// Not full code, just a snippet...
{
	_groupName = _x select 0;
	_group = _x select 1;
	_index = _groupList lbAdd format ["%1", _groupName];
	_groupList lbSetData [_index, (format ["%1", _group])];
} forEach groups;

// Another file, snippet code...
private _groupSelected = _groupList lbData 0;

// hintSilent format ["Group Selected > %1 || %2", _groupSelected, typeName (call compile _groupSelected)];
// The above is wrong, had that in the video example, my bad
hintSilent format ["Group Selected > %1 || %2", _groupSelected, typeName _groupSelected];
[player] joinSilent (call compile _groupSelected);

When I do this:

((player getVariable "groupData") select 1)

Works, joins me to the group.

typeName ((player getVariable "groupData") select 1)

Data type returns GROUP as well.

Share this post


Link to post
Share on other sites

Solved! Not possible to do what I actually wanted: Convert STRING to GROUP

I didn't actually need to use lbSetData or lbSetValue in the end in this case because I populate the listbox in order from added to array. I used lbCurSel:

private _groupSelected = groups select (lbCurSel _groupList) select 1;

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×