dwpenney Posted June 5, 2013 Posted June 5, 2013 Does anyone have any examples that they can share where, in a lua script, you add/remove commands from the f10 radio? Fridge ---------- Things which do you no good in aviation: 1) Altitude above you; 2) Runway behind you; 3) Fuel in the truck; 4) The airspeed you don't have.
Druid_ Posted June 5, 2013 Posted June 5, 2013 Just happened to have tested for 1.2.3 and it was still sitting there in notepad++ so ... ADD:- trigger.action.addOtherCommandForCoalition(coalition.side.BLUE, 'Request SAR cover', 40) REMOVE:- trigger.action.removeOtherMenuItemForCoalition(coalition.side.BLUE, 'Request SAR cover') i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
dwpenney Posted June 5, 2013 Author Posted June 5, 2013 Is there some option that does not use triggers? Something that might call a lua function instead? I saw this one on the scripting wiki but I can't figure out how I might create a CommandFunction Path missionCommands.addCommand(string name, Path or nil path, CommandFunction сommandFunction, any argument) Fridge ---------- Things which do you no good in aviation: 1) Altitude above you; 2) Runway behind you; 3) Fuel in the truck; 4) The airspeed you don't have.
dwpenney Posted June 5, 2013 Author Posted June 5, 2013 More info: I am working on a script that can be plugged into a mission and generate dynamic downed pilots that can be rescued by SAR units. It doesn't use triggers but periodic LOS calculations to determine when to initiate events. I am working on how I can, as I have seen missions with triggers do, have a recovery team spawn or have the pilot move to the SAR unit. Before I get more complicated with my code, I'd like to see if I can trigger a couple of these 'behaviours' from the radio list. Fridge ---------- Things which do you no good in aviation: 1) Altitude above you; 2) Runway behind you; 3) Fuel in the truck; 4) The airspeed you don't have.
RagnarDa Posted June 5, 2013 Posted June 5, 2013 (edited) The code Druid posted is Lua-script without using triggers. I guess what you mean is without using flags. Without having tested it first I think you could just do something like this: missionCommands.addCommand( "My radioitem #1", nil, function (My_Argument) ... code goes here ... end, My_Argument) Edited June 5, 2013 by RagnarDa DCS AJS37 HACKERMAN There will always be bugs. If everything is a priority nothing is.
dwpenney Posted June 5, 2013 Author Posted June 5, 2013 Holy wow! It is _that_ easy! I was expecting some work to cast a function as a CommandFunction - I must be over thinking it :-) function PilotDown.radioCommand (test_text) msg.text = PilotDown::radioCommand (): " .. test_text msg.displayTime = duration msg.msgFor = {coa = {coalition}} mist.message.add (msg) mist.debug.dump_G ("PilotDown-main-radio_command-dump_G.log") end [...] PilotDown.tmp_data = missionCommands.addCommand ("SAR Test and Debug", nil, PilotDown.radioCommand, "Test and Debug") path_data was a table that looked like this in the mist dump: ["PilotDown"]["tmp_data"] = table: 0000000021EE2860 { ["PilotDown"]["tmp_data"][1] = "SAR Test and Debug", }, Sure enough, under the comms F10 menu my SAR Test and Debug option was there and selecting it triggered the message and the mist dump. Easy. :-) Now I have to figure out my coalition stuff to only get those messages to show for the correct side. Is it going to be that simple to add options under the "SAR Test and Debug" comm menu by passing the tmp_data table to subsequent addCommand calls in the path parameter? Can I just pass nil for the command and argument in that case or do I have to have an 'empty' command (a command that does nothing)? Can I even add commands under the SAR Test and Debug command (like a tree)? Fridge ---------- Things which do you no good in aviation: 1) Altitude above you; 2) Runway behind you; 3) Fuel in the truck; 4) The airspeed you don't have.
RagnarDa Posted June 5, 2013 Posted June 5, 2013 Now I have to figure out my coalition stuff to only get those messages to show for the correct side. Replace missionCommands.addCommand with missionCommands.addCommandForCoalition :smilewink: Is it going to be that simple to add options under the "SAR Test and Debug" comm menu by passing the tmp_data table to subsequent addCommand calls in the path parameter? Can I just pass nil for the command and argument in that case or do I have to have an 'empty' command (a command that does nothing)? Can I even add commands under the SAR Test and Debug command (like a tree)? From what I can see: YES! :P DCS AJS37 HACKERMAN There will always be bugs. If everything is a priority nothing is.
galevsky06 Posted July 11, 2013 Posted July 11, 2013 Hello everybody, Just a question: I need to get the unit name of the human who executed the F10 missionCommands: I can attach the whole F10 menu to each new human when spawing with missionCommands.addCommandForGroup() with groupId as an input parameter to the function executed. I would like to do missionCommands.addCommandForCoalition() once , but how to fetch the name of the unit ? Not possible ? Thank you
Joyride Posted September 29, 2013 Posted September 29, 2013 Curious if anyone has been able to nest an addCommand within a submenu. I can't figure out what needs to be used for "path" to get the addCommand menu item into the desired submenu. Any luck?
galevsky06 Posted September 29, 2013 Posted September 29, 2013 Yes it works: local MiscPath = missionCommands.addSubMenu("Misc",nil) missionCommands.addCommand("Assign menu to all clients", MiscPath, assignF10MenuToClients, nil) missionCommands.addCommand("Print client forces", MiscPath, printForces, nil) Path = nil when it is main menu Can be a parent path to become a submenu. 1
galevsky06 Posted September 30, 2013 Posted September 30, 2013 Works perfect, thanks galevsky06. You are welcom' :)
HiJack Posted April 17, 2014 Posted April 17, 2014 Just happened to have tested for 1.2.3 and it was still sitting there in notepad++ so ... ADD:- trigger.action.addOtherCommandForCoalition(coalition.side.BLUE, 'Request SAR cover', 40) REMOVE:- trigger.action.removeOtherMenuItemForCoalition(coalition.side.BLUE, 'Request SAR cover') Any plans to fix this command? Can't seem to get it working as described.
RagnarDa Posted April 17, 2014 Posted April 17, 2014 Any plans to fix this command? Can't seem to get it working as described. If the update hasn't broken it I believe it has been working for a while. Check out my scripts here http://forums.eagle.ru/showthread.php?t=107303 or better here http://forums.eagle.ru/showpost.php?p=1756962&postcount=20 DCS AJS37 HACKERMAN There will always be bugs. If everything is a priority nothing is.
ESAc_matador Posted June 12, 2016 Posted June 12, 2016 (edited) hello fellas, i have this problem. I add this. local _path1 = missionCommands.addSubMenuForCoalition(coalition.side.BLUE,"Ground units", nil) local _path2 = missionCommands.addSubMenuForCoalition(coalition.side.BLUE,"All groups", _path1) local _path3 = missionCommands.addSubMenuForCoalition(coalition.side.BLUE,"CAS Support", nil) local _path4 = missionCommands.addSubMenuForCoalition(coalition.side.BLUE,"CAS1", _path3) missionCommands.addCommandForCoalition(coalition.side.BLUE, "Mark enemy troops with blue smoke",_path2, function ()reconmarkerblue()end, nil) missionCommands.addCommandForCoalition(coalition.side.BLUE, "Report enemy situation",_path2, function ()reconadviseblue()end, nil) [code/] and in the middle of the game I add also this in the _path4 [code] missionCommands.addCommandForCoalition(coalition.side.BLUE,targetgrouppos, [b]_path4,[/b] function ()CASattack()end, nil) [code/] what happen is... instead of show in _path4 as ordered it goes to the main root of F10... it works, but not in the place it should.... I getting crazy here!!! Edited June 12, 2016 by ESAc_matador
Steggles Posted June 12, 2016 Posted June 12, 2016 You've declared _path4 local. Is it still in scope when trying to add the command to the menu? Is it in a file or just using the DO SCRIPT action in the mission editor? Not sure if local variables remain in scope if using the DO SCRIPT in the editor. Nice work digging up a 2-3 year old post too :P -16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com EWRS - Early Warning Radar Script Specs: Gigabyte Sniper Z5-S Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler 16GB RAM Gigabyte GTX 1080 TM Hotas Warthog: SN: 06976 Saitek Pro Flight Combat Rudder Pedals TrackIR5 with TrackClipPro & Oculus Rift 2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024
ESAc_matador Posted June 12, 2016 Posted June 12, 2016 (edited) I am asking many things!... I try to keep the forum clean! And thanks for the answer! It make sense, i declare path4 ina function called at the beggining and the function is closed when I called the nrw one. i am in "starting to create lua things fever" mode!. Edited June 12, 2016 by ESAc_matador
GTFreeFlyer Posted July 4, 2019 Posted July 4, 2019 (edited) I use LUA to build a nested menu, but am trying to figure out how to remove a command. Example snippet below from a section of the menu you'll see after clicking "AI Hornets" in the main menu. After issuing the "Start Up" command for either of the Hornets below, how can I remove the command from the list and leave the CAP and RTB where they are? I can't find the function. Thanks! [color=#d4d4d4][font=Consolas][color=Black]local AIHornetMenu = missionCommands.addSubMenu("AI Hornets", nil) local AIHornet5Menu = missionCommands.addSubMenu("Hornet 5 (CAP)", AIHornetMenu) missionCommands.addCommand("Start Up", AIHornet5Menu, function() trigger.action.setUserFlag(9, 1) end, nil) missionCommands.addCommand("Fly CAP", AIHornet5Menu, function() trigger.action.setUserFlag(9, 17) end, nil) missionCommands.addCommand("RTB", AIHornet5Menu, function() trigger.action.setUserFlag(9, 10) end, nil) local AIHornet6Menu = missionCommands.addSubMenu("Hornet 6 (SEAD)", AIHornetMenu) missionCommands.addCommand("Start Up", AIHornet6Menu, function() trigger.action.setUserFlag(10, 1) end, nil) missionCommands.addCommand("Fly SEAD", AIHornet6Menu, function() trigger.action.setUserFlag(10, 17) end, nil) missionCommands.addCommand("RTB", AIHornet6Menu, function() trigger.action.setUserFlag(10, 10) end, nil) [/color][/font][/color] Edited July 4, 2019 by GTFreeFlyer 1 My DCS Missions: Band of Buds series | The End of the T-55 Era | Normandy PvP | Host of the Formation Flight Challenge server Supercarrier Reference Kneeboards IRL: Private Pilot, UAS Test Pilot, Aircraft Designer, and... eh hem... DCS Enthusiast
Hardcard Posted July 4, 2019 Posted July 4, 2019 (edited) I use LUA to build a nested menu, but am trying to figure out how to remove a command. Example snippet below from a section of the menu you'll see after clicking "AI Hornets" in the main menu. After issuing the "Start Up" command for either of the Hornets below, how can I remove the command from the list and leave the CAP and RTB where they are? I can't find the function. Thanks! [color=#d4d4d4][font=Consolas][color=Black]local AIHornetMenu = missionCommands.addSubMenu("AI Hornets", nil) local AIHornet5Menu = missionCommands.addSubMenu("Hornet 5 (CAP)", AIHornetMenu) missionCommands.addCommand("Start Up", AIHornet5Menu, function() trigger.action.setUserFlag(9, 1) end, nil) missionCommands.addCommand("Fly CAP", AIHornet5Menu, function() trigger.action.setUserFlag(9, 17) end, nil) missionCommands.addCommand("RTB", AIHornet5Menu, function() trigger.action.setUserFlag(9, 10) end, nil) local AIHornet6Menu = missionCommands.addSubMenu("Hornet 6 (SEAD)", AIHornetMenu) missionCommands.addCommand("Start Up", AIHornet6Menu, function() trigger.action.setUserFlag(10, 1) end, nil) missionCommands.addCommand("Fly SEAD", AIHornet6Menu, function() trigger.action.setUserFlag(10, 17) end, nil) missionCommands.addCommand("RTB", AIHornet6Menu, function() trigger.action.setUserFlag(10, 10) end, nil) [/color][/font][/color] I think this is what you're looking for: https://wiki.hoggitworld.com/view/DCS_func_removeItem Also, take a look at this: https://forums.eagle.ru/showpost.php?p=2954080&postcount=4 From what I understood, you need to include the commands in a table (assigning them custom indices), then reference these custom indices when you want to remove the commands they are associated with. Here, I've modified your snippet, this should do it: local AIHornetMenu = missionCommands.addSubMenu("AI Hornets", nil) local AIHornet5Submenu = {} local AIHornet5Menu = missionCommands.addSubMenu("Hornet 5 (CAP)", AIHornetMenu) AIHornet5Submenu['Start Up'] = missionCommands.addCommand("Start Up", AIHornet5Menu, function() trigger.action.setUserFlag(9, 1) missionCommands.removeItem(AIHornet5Submenu['Start Up']) end, nil) AIHornet5Submenu['Fly CAP'] = missionCommands.addCommand("Fly CAP", AIHornet5Menu, function() trigger.action.setUserFlag(9, 17) end, nil) -- Should be removed when the group dies, so it has a custom index AIHornet5Submenu['RTB'] = missionCommands.addCommand("RTB", AIHornet5Menu, function() trigger.action.setUserFlag(9, 10) end, nil) -- Should be removed when the group dies / lands, so it has a custom index local AIHornet6Submenu = {} local AIHornet6Menu = missionCommands.addSubMenu("Hornet 6 (SEAD)", AIHornetMenu) AIHornet6Submenu['Start Up'] = missionCommands.addCommand("Start Up", AIHornet6Menu, function() trigger.action.setUserFlag(10, 1) missionCommands.removeItem(AIHornet6Submenu['Start Up']) end, nil) AIHornet6Submenu['Fly SEAD'] = missionCommands.addCommand("Fly SEAD", AIHornet6Menu, function() trigger.action.setUserFlag(10, 17) end, nil) -- Should be removed when the group dies, so it has a custom index AIHornet6Submenu['RTB'] = missionCommands.addCommand("RTB", AIHornet6Menu, function() trigger.action.setUserFlag(10, 10) end, nil) -- Should be removed when the group dies / lands, so it has a custom index Edited July 4, 2019 by Hardcard [sIGPIC][/sIGPIC]
GTFreeFlyer Posted July 4, 2019 Posted July 4, 2019 I think this is what you're looking for: https://wiki.hoggitworld.com/view/DCS_func_removeItem Also, take a look at this: https://forums.eagle.ru/showpost.php?p=2954080&postcount=4 From what I understood, you need to include the commands in a table (assigning them custom indices), then reference these custom indices when you want to remove the commands they are associated with. Here, I've modified your snippet, this should do it: local AIHornetMenu = missionCommands.addSubMenu("AI Hornets", nil) local AIHornet5Submenu = {} local AIHornet5Menu = missionCommands.addSubMenu("Hornet 5 (CAP)", AIHornetMenu) AIHornet5Submenu['Start Up'] = missionCommands.addCommand("Start Up", AIHornet5Menu, function() trigger.action.setUserFlag(9, 1) missionCommands.removeItem(AIHornet5Submenu['Start Up']) end, nil) AIHornet5Submenu['Fly CAP'] = missionCommands.addCommand("Fly CAP", AIHornet5Menu, function() trigger.action.setUserFlag(9, 17) end, nil) -- Should be removed when the group dies, so it has a custom index AIHornet5Submenu['RTB'] = missionCommands.addCommand("RTB", AIHornet5Menu, function() trigger.action.setUserFlag(9, 10) end, nil) -- Should be removed when the group dies / lands, so it has a custom index local AIHornet6Submenu = {} local AIHornet6Menu = missionCommands.addSubMenu("Hornet 6 (SEAD)", AIHornetMenu) AIHornet6Submenu['Start Up'] = missionCommands.addCommand("Start Up", AIHornet6Menu, function() trigger.action.setUserFlag(10, 1) missionCommands.removeItem(AIHornet6Submenu['Start Up']) end, nil) AIHornet6Submenu['Fly SEAD'] = missionCommands.addCommand("Fly SEAD", AIHornet6Menu, function() trigger.action.setUserFlag(10, 17) end, nil) -- Should be removed when the group dies, so it has a custom index AIHornet6Submenu['RTB'] = missionCommands.addCommand("RTB", AIHornet6Menu, function() trigger.action.setUserFlag(10, 10) end, nil) -- Should be removed when the group dies / lands, so it has a custom index Thanks! I haven’t tested it yet but will when I get home later. I appreciate it! My DCS Missions: Band of Buds series | The End of the T-55 Era | Normandy PvP | Host of the Formation Flight Challenge server Supercarrier Reference Kneeboards IRL: Private Pilot, UAS Test Pilot, Aircraft Designer, and... eh hem... DCS Enthusiast
GTFreeFlyer Posted July 4, 2019 Posted July 4, 2019 It works! Thanks so much! My DCS Missions: Band of Buds series | The End of the T-55 Era | Normandy PvP | Host of the Formation Flight Challenge server Supercarrier Reference Kneeboards IRL: Private Pilot, UAS Test Pilot, Aircraft Designer, and... eh hem... DCS Enthusiast
Recommended Posts