AKA_Clutter Posted August 26, 2024 Posted August 26, 2024 (edited) OK, I have no idea if what I am trying to do is possible. What I would like to do is capture the 'menuID" of a F10 Other submenu assigned by another script and then pass it to a separate script so that I can add to the sub menu. I would like to do this rather than try and modify the other script to include mine. For example, Script #1 sets up the follow f10 Other F10 Other F1 - Menu item 1 F1 - Menu F1 submenu F1 F2 - Menu F1 submenu F2 I would like to capture the path given to "F1- Menu item 1" and pass it to a second script, so that other script could add item "F3- menu F1 submenu F3" So that I end up with F10 Other F1 - Menu item 1 F1 - Menu F1 submenu F1 F2 - Menu F1 submenu F2 F3 - Menu F1 submenu F3 I have tried this with the code snippets below but all I get is F10 Other F1 - Menu item 1 F1 - Menu F1 submenu F1 F2 - Menu F1 submenu F2 F2 - menu F1 submenu F3 So is it possible to do what I am trying to do. Snippet from the script file that generates the initial F10 Other menu (This works fine, although it may be clumsy) local menuID = missionCommands.addSubMenuForCoalition('2' , 'Scout Recon Missions') globalMenuID = menuID for i=1, Squd_Type_Max-1 do missionCommands.addCommandForCoalition('2' , TBL_Sqaud_Names[i][1] , menuID , Activate_Scout_Target_Squad,i) end -- Add submenu for Random call, menu item # should be Squd_Type_Max missionCommands.addCommandForCoalition('2' , TBL_Sqaud_Names[Squd_Type_Max][1] , menuID , Scout_Recon_Random_Group_Main,Squd_Type_Max) Script to try and use the global variable. This is done 30 seconds after the script above. function menuTest () trigger.action.outText("\n=============================\n\nSIMPLE TEST OF PASSING MENU IDn.\n\n=============================", 15) end missionCommands.addCommandForCoalition('2' , "Simple Test Of Passing Menu item" , globalMenuID, menuTest) Thanks for the help. Edited August 26, 2024 by AKA_Clutter Add text to make things clearer. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Grimes Posted August 27, 2024 Posted August 27, 2024 I would think if you just did it as glbalMenuID = missionCommands.addSubMenu it would work. If you know the strings that make-up the sub menu items then you should be able to directly use that. The path entry is just a table indexed numerically. The following ought to work. missionCommands.addCommandForCoalition('2' , "Simple Test Of Passing Menu item" , {'Scout Recon Missions'}, menuTest) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
AKA_Clutter Posted August 27, 2024 Author Posted August 27, 2024 24 minutes ago, Grimes said: I would think if you just did it as glbalMenuID = missionCommands.addSubMenu it would work. If you know the strings that make-up the sub menu items then you should be able to directly use that. The path entry is just a table indexed numerically. The following ought to work. missionCommands.addCommandForCoalition('2' , "Simple Test Of Passing Menu item" , {'Scout Recon Missions'}, menuTest) Hi @Grimes thanks for the response. I'm not sure what I did earlier, but I went back added a simple text variable to pass as an additional test just to verify that what I thought would be a global variable was indeed global. And indeed they are. Funny thing is after that, the script snippets did work as expected. I thought that perhaps I call the initial F10 Other before the second snippets was called and that screwed things up. But that doesn't seem to be it either. It works now and the new sub menu item shows up as intended. With that said, I'll play around with your two suggestions just as various ways to solve the same problem. The initial problem I am trying to solve is that in one of our squad training missions, the F10 Other menu is populated by a script written by someone else. It generates the F10 other menu based on a naming scheme. I would like to add some other submenu items to the ones that are auto generated. Again, thanks for the response and help. Clutter ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
AKA_Clutter Posted August 28, 2024 Author Posted August 28, 2024 2 hours ago, Grimes said: If you know the strings that make-up the sub menu items then you should be able to directly use that. The path entry is just a table indexed numerically. The following ought to work. @Grimes Two questions: 1) is this path entry table accessible/readable? I didn't see any reference to this in the wiki. Of course, it is very likely that I overlooked it. 2) Directly using it does appear to work for the first level below F10 Other. Any idea how to do this for a sub-sub menu. F10Other -> Level 1 -> Level 2 I've tried a couple of things but no joy yet. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Solution Grimes Posted August 28, 2024 Solution Posted August 28, 2024 1. It is just a table, it'll be the same way accessing any other table. Though in this instance everything is indexed numerically, thus a for i =1, #table do will give you the table in order. The wiki just mentions it on the main missionCommand pages. I didn't include examples in the forGroup or forCoalition versions because its literally the same. https://wiki.hoggitworld.com/view/DCS_singleton_missionCommands { [1] = "SubMenuInRoot", [2] = "Sub1", [3] = "Sub2", } 2. Think of it as a table structure. If you wanted to add a menu at level 2 then you'd use a path that goes up to that point. missionCommands.addCommandForCoalition('2' , "Simple Test Of Passing Menu item" , {'SubMenuInRoot', "Sub1"}, menuTest) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
AKA_Clutter Posted August 28, 2024 Author Posted August 28, 2024 @Grimes Thanks so V ERY much. Now that I look closer at the Wiki, all the information is there, I just need to learn how to read the Wiki and the DCS API better. Also, still a newbie with lua. When I get a chance, I think I'll play around with this and see if I understand everything correctly. One thing I want to do is to 1 ) figure out how to get the complete table and then rpint it to a file just to see what it looks like. Thanks again for your knowledge and willingness to help Clutter ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Recommended Posts