Flinty 454 Posted December 27, 2017 Hi all I'm currently developing an armory script for my milsim unit and I've run into some issues. I'm wondering, how would I go about doing the following: Having a large list of loadouts in one Listbox and when an option is chosen, different variations appear in the next listbox, which can then be loaded from pressing a Load button. I've thought about using a bunch of if statements, but I wouldn't really know how to implement it. Say for example you could name each listbox option separately (e.g. ListBox_1 Listbox_2 etc etc), then you can use a variety of If then statements to finish it off, but asides that I've got no concrete idea on how I would do it. Any suggestions/help would be appreciated! Cheers, Flint Share this post Link to post Share on other sites
Larrow 2779 Posted December 27, 2017 (edited) Just a simple example to get the idea across. TAG_loadouts = [ "loadout1", "loadout2", "loadout3" ]; TAG_loadoutVariants = [ //loadout1 [ [ "L1_V1", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L1_V2", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L1_V3", /*Some form of loadout, VA export or scriptname etc*/ ] ], //loadout2 [ [ "L2_V1", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L2_V2", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L2_V3", /*Some form of loadout, VA export or scriptname etc*/ ] ], //loadout3 [ [ "L3_V1", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L3_V2", /*Some form of loadout, VA export or scriptname etc*/ ], [ "L3_V3", /*Some form of loadout, VA export or scriptname etc*/ ] ] ]; //Some function called from display onLoad EH TAG_fnc_initGUI = { params[ "_display" ]; //Get listboxs _listBox1 = _display displayCtrl #; //Replace with IDC _listBox2 = _display displayCtrl #; //Replace with IDC //Fill first with loadout names { _listBox1 lbAdd _x; }forEach TAG_loadouts; //Add EH for when a listbox1 selection is made _listBox1 ctrlAddEventHandler [ "LBSelChanged", { params[ "_ctrl", "_index" ]; //Get listbox2 _listBox2 = ctrlParent _ctrl displayCtrl #; //Replace with IDC //Clear listboxes current entries lbClear _listBox2; //Fill it with names based off of selected index used in listbox1 { _listBox2 lbAdd ( _x select 0 ); }forEach ( TAG_loadoutVariants select _index ); //Reset listbox2 selection to nothing _listBox2 lbSetCurSel -1; }]; //Automatically select listbox1 first item //This will cause the above event to fire filling listbox2 _listBox1 lbSetCurSel 0; //Add EH for when LOAD button is pressed _loadButton = _display displayCtrl #;//Replace with IDC _loadButton ctrlAddEventHandler [ "ButtonClick", { params[ "_ctrl" ]; //Get listboxs _listBox1 = ctrlParent _ctrl displayCtrl #; //Replace with IDC _listBox2 = ctrlParent _ctrl displayCtrl #; //Replace with IDC _inventory = TAG_loadoutVariants select ( lbCurSel _listBox1 ) select ( lbCurSel _listBox2 ) select 1; //Do something with inventory reference //Close the UI closeDialog 1; }]; //Disable LOAD button until a selection is made in listBox2 _loadButton ctrlEnable false; //When a selection in listbox2 is made _listBox2 ctrlAddEventHandler [ "LBSelChanged", { params[ "_ctrl", "_index" ]; //Get the LOAD button _loadButton = ctrlParent _ctrl displayCtrl #;//Replace with IDC //If we have a selection. Will be -1 when listbox2 is refreshed by listbox1 selection EH if ( _index > -1 ) then { //Enable button, we have a valid selection _loadButton ctrlEnable true; }else{ //Disable button, the listbox has loaded new variants _loadButton ctrlEnable false; }; }]; }; Edited December 28, 2017 by Larrow Cleared listBox2 on filling, added LOAD button handling 2 Share this post Link to post Share on other sites
Flinty 454 Posted December 27, 2017 So would I be correct in saying TAG_loadouts is the contents of the list, TAG_loadoutVariants are the variants in the second box and I just add this kind of thing in with onLoad correct? Cheers Share this post Link to post Share on other sites
Larrow 2779 Posted December 28, 2017 19 hours ago, Flinty said: So would I be correct in saying TAG_loadouts is the contents of the list, TAG_loadoutVariants are the variants in the second box and I just add this kind of thing in with onLoad correct? Cheers Correct Share this post Link to post Share on other sites