OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Rommel92 on 15 Jun 2008, 07:34:03

Title: ForEach Problem?
Post by: Rommel92 on 15 Jun 2008, 07:34:03
Code: [Select]
_MenuPlatoons = [];
{
_MenuPlatoons = _MenuPlatoons +
[
[["Item",_x + ". Platoon"],["SubMenu", _x +"PMenu"]]
]
} forEach ["1","2","3","4"];

_MenuInnerPlatoons =[];
{
_MenuInnerPlatoons = _MenuInnerPlatoons +
[_x + "PMenu",
[
["Caption", _x + " Platoon"],
["Items",
[
[ ["Item", "-"] ],
[ ["Item", "Test1"], ["SubMenu", ""] ],
[ ["Item", "Test2"], ["SubMenu", ""] ],
[ ["Item", "-"] ],
[ ["Item", "Close Menu"],["Close", true],["Default", true] ]
]
]
]
]
} forEach ["1","2","3","4"];

_MenuStructureArray =
[
["MainMenu",
[
["Caption", "Men"],
["Items",
[
[ ["Item", "-"] ],
[ ["Item", "Platoons >"], ["SubMenu", "Platoons"] ],
[ ["Item", "Support >"], ["SubMenu", "Support"] ],
[ ["Item", "-"] ],
[ ["Item", "Close Menu"],["Close", true],["Default", true] ]
]
]
]
],

["Platoons",
[
["Caption", "Platoons"],
["Items", _MenuPlatoons]
]
],

["FireTeams",
[
["Caption", "Operators"],
["Items",
[
[ ["Item", "RFL FireTeam [4]"], ["Action", "[player, 4,0] execVM 'Scripts\C3IS\X_FIRETEAM.sqf'"], ["Close", false] ],
[ ["Item", "GUN FireTeam [4]"], ["Action", "[player, 4,1] execVM 'Scripts\C3IS\X_FIRETEAM.sqf'"], ["Close", false] ],
[ ["Item", "ASLT FireTeam [4]"], ["Action", "[player, 4,2] execVM 'Scripts\C3IS\X_FIRETEAM.sqf'"], ["Close", false] ]
]
]
]
]
] + [_MenuInnerPlatoons];
_MenuStructureArray execVM "Dialogs\ICE.sqf";

http://pb.6thsense.eu/pb/92

Everything works great, however it will not add the menus for "2","3","4" IN the _MENUINNERPLATOONS, however it works for the _MenuPlatoons... why is this? (If anyone needs more info/demonstration/details then just ask).

(http://img204.imageshack.us/img204/4526/tesetxk0.jpg)
Title: Re: ForEach Problem?
Post by: Rommel92 on 15 Jun 2008, 08:14:52
Solved.

Top of code to ->
Code: [Select]
_MenuInnerPlatoons =[];
{
_MenuInnerPlatoons = _MenuInnerPlatoons +
[
[_x + "PMenu",
[
["Caption", _x + " Platoon"],
["Items",
[
[ ["Item", "-"] ],
[ ["Item", "Test1"], ["SubMenu", ""] ],
[ ["Item", "Test2"], ["SubMenu", ""] ],
[ ["Item", "-"] ],
[ ["Item", "Close Menu"],["Close", true],["Default", true] ]
]
]
]
]
]
} forEach ["1","2","3","4"];

Code: [Select]
] + [_MenuInnerPlatoons];
To ->
Code: [Select]
] + _MenuInnerPlatoons;

*Cracks open Champagne*

 :D