Mt5_Roie Posted January 23, 2016 Posted January 23, 2016 So I have a training map I'm working on and I'd like to tidy up the radio functions. So I wrote the following code to try to do it. function setuserflag(x) trigger.setUserFlag(x,1) end local _path1 = missionCommands.addSubMenu("Air To Air Ranges", nil) local _path2 = missionCommands.addSubMenu("Air To Ground Ranges", nil) local _path3 = missionCommands.addSubMenu(“Helicopter Ranges”, nil) missionCommands.addCommand("Activate Su-27 Guns Only”, _path1,setuserflag, 160) missionCommands.addCommand("Activate Mig-23 IR Missiles”, _path1,setuserflag, 170) missionCommands.addCommand("Activate Su-27 BVR”, _path1,setuserflag, 180) missionCommands.addCommand("Activate Mig-29 BVR”, _path1,setuserflag, 190) missionCommands.addCommand("Activate Armor Alley”, _path2,setuserflag, 100) missionCommands.addCommand("Activate Moving Convoy”, _path2,setuserflag, 200) missionCommands.addCommand("Activate CSAR Range”, _path3,setuserflag, 150) The menus part works fine and I see things where they need to be...but when you actually click on a command (i.e Activate Su27 Guns only) it doesn't seem to set the flag I want to 1. Essentially I have rules to look for when a flag is turned on (or set to 1) and then activate that range. So I was hoping the code above would set those flags, but that doesn't seem to be working. Any advice? Coder - Oculus Rift Guy - Court Jester
Mt5_Roie Posted January 26, 2016 Author Posted January 26, 2016 So was able to figure out my issue and got it working...here's my code now: local _path1 = missionCommands.addSubMenu("Air To Air Ranges", nil) local _path2 = missionCommands.addSubMenu("Air To Ground Ranges", nil) local _path3 = missionCommands.addSubMenu("Helicopter Ranges", nil) missionCommands.addCommand("Activate Su-27 Guns Only",_path1,function() trigger.action.setUserFlag("160",true) end,nil) missionCommands.addCommand("Activate Mig-23 IR Missiles",_path1,function() trigger.action.setUserFlag("170",true) end,nil) missionCommands.addCommand("Activate Su-27 BVR",_path1,function() trigger.action.setUserFlag("180",true) end,nil) missionCommands.addCommand("Activate Mig-29 BVR",_path1,function() trigger.action.setUserFlag("190",true) end,nil) missionCommands.addCommand("Activate Armor Alley",_path2,function() trigger.action.setUserFlag("100",true) end,nil) missionCommands.addCommand("Activate Moving Convoy",_path2,function() trigger.action.setUserFlag("200",true) end,nil) missionCommands.addCommand("Activate CSAR Range",_path3,function() trigger.action.setUserFlag("150",true) end,nil) trigger.action.outText("Menu Items should be loaded now",10) Problem I have now is that I want to remove individual commands in the menus. So if I do: missionCommands.removeItem({"Activate CSAR Range"}) it doesn't remove the item....but if I do missionCommands.removeItem({"Helicopter Ranges"}) it removes the whole submenu. Is there a way to just remove one command and not the whole submenu? Otherwise I would have to check each individual flag and re-create the menu each time something changed. Coder - Oculus Rift Guy - Court Jester
Steggles Posted January 26, 2016 Posted January 26, 2016 (edited) Haven't tried it, but try removeOtherCommand instead of removeItem. edit: The wiki has removeOtherCommand as a trigger.action and not missionCommands. http://wiki.hoggit.us/view/DCS_func_removeOtherCommand Edited January 26, 2016 by Steggles -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
Mt5_Roie Posted January 26, 2016 Author Posted January 26, 2016 So I tried the following: trigger.action.removeOtherCommand("Activate Su-27 Guns Only") While it didn't give an error, it didn't seem to remove it either. I tried various variants of it (like using { } before and after the quotes) but it got errors or crashed the sim all together. Somedays I think I should just stick to flying..... Coder - Oculus Rift Guy - Court Jester
Recommended Posts