Scotty123 10 Posted May 24, 2014 I have an array of classnames for various uniforms, eg uniformClasses = ["U_O_GhilleSuit",.....]; I use the following below for "_x" from 0 to count uniformClasses - 1 do { _array = [format["%1", getText(configFile >> "Cfgweapons" >> uniformClasses select _x >> "displayName")], [12], "", -5, [["expression", "player adduniform (uniformClasses select _x)"]], "1", "1"]; testMenu set [_x + 2, _array]; }; showcommandingmenu "#USER:testMenu"; This doesn't work. I see the list of uniforms, but selecting one does nothing. I used a hint instead to see what value was being received - [["expression", "hint format[""%1"",(uniformClasses select _x)]"]]. Result is any and obviously just the same with the loop variable. Now I could just write everything out manually, but I would rather not. Having the array allows the insertion and removal of items easily, without having to enter in new menu lines. Any ideas or work arounds? Thanks! Share this post Link to post Share on other sites
f2k sel 164 Posted May 24, 2014 (edited) I'd also like to know the answer. I did try what you posted above but couldn't even get the list to appear, I do get a blank box. Is there anything missing from the above? I wonder if you can't pass a local variable _x into expression maybe it needs to be global or use setvariable to pass it to expression. Edited May 24, 2014 by F2k Sel Share this post Link to post Share on other sites
Scotty123 10 Posted May 24, 2014 (edited) This is the code in full. uniformClasses = [ "U_O_SpecopsUniform_ocamo", "U_O_GhillieSuit", "U_O_PilotCoveralls" ]; testMenu =[["test",true]]; for "_x" from 0 to count uniformClasses - 1 do { _array = [format["%1", getText(configFile >> "Cfgweapons" >> uniformClasses select _x >> "displayName")], [12], "", -5, [["expression", "player adduniform (uniformClasses select _x)"]], "1", "1"]; testMenu set [_x + 2, _array]; }; showcommandingmenu "#USER:testMenu"; The work around so far is to use [format["%1", getText(configFile >> "Cfgweapons" >> uniformClasses select 0 >> "displayName")], [12], "", -5, [["expression", "player adduniform (uniformClasses select 0)" ]], "1", "1"] Spam that however many times needed, increasing the index by one. It's just messy and I think there must be a more elegant way of producing it using loops. Edited May 24, 2014 by Scotty123 Share this post Link to post Share on other sites
f2k sel 164 Posted May 24, 2014 Yea I was missing the the second set of [] around testmenu, thanks. Looks like I was right about _x it's not allowed, you need to swap it out. uniformClasses = [ "U_O_SpecopsUniform_ocamo", "U_O_GhillieSuit", "U_O_PilotCoveralls" ]; testMenu =[["test",true]]; for "_x" from 0 to count uniformClasses - 1 do { player setvariable ["varX",_x]; _array = [format["%1", getText(configFile >> "Cfgweapons" >> uniformClasses select _x >> "displayName")], [12], "", -5, [["expression", "player adduniform (uniformClasses select (player getvariable 'varX'))"]], "1", "1"]; testMenu set [_x + 2, _array]; }; showcommandingmenu "#USER:testMenu"; Share this post Link to post Share on other sites
Scotty123 10 Posted May 24, 2014 I find that only spawns the last item in the array. Share this post Link to post Share on other sites
f2k sel 164 Posted May 24, 2014 Damn it I hadn't noticed that, it's odd the first part works. Share this post Link to post Share on other sites
Scotty123 10 Posted May 24, 2014 I am thinking the first part works as that is set up for you, before you execute anything. When you choose an option, the expression executes. It's not created with code until then. _x has been destroyed hence is nil. If we use your method, it's at its last value, hence why I get the last item. Share this post Link to post Share on other sites
f2k sel 164 Posted May 24, 2014 Yea I've come to the same conclusion, there just doesn't seem to be a way of pointing to an array while creating the menu structure in this part of the script. I did wonder if it could be created after the menu structure has been created but I'm not very good at replacing nested variables. Other than that I can't see anyway forward. Share this post Link to post Share on other sites