DCS func removeItem

From DCS World Wiki - Hoggitworld.com

Scripting Root

Envrioment: Mission Scripting
Function: removeItem Added with: 1.2.4
Member Of: missionCommands
Syntax: nothing missionCommands.removeItem(table/nil path )
Description: Removes the item of the specified path from the F10 radio menu for all. If the value is nil all items will be removed from the radio menu. If the path given is a submenu then all items nested within will be removed.


Return Value: nothing
Return Example: none
Examples: The following would remove a command named "Test Command" that is listed in the root menu.
 missionCommands.removeItem({[1] = "Test Command"})

Here is a relatively simple setup to save possibly multiple paths for commands generated for the purpose of removing it at a later time. When an command is created it is stored in the commandDB table. When the player selects "Warning Message" in their F10 menu the player will be informed that someone is taking the Hobbits to Isengard, repeatedly. At the end of the function it calls the removeItem function to remove the path with the name "Isengard" from the commandDB table.

 local commandDB = {}
 local function removeItem(name) 
   missionCommands.removeItem(commandDB[name])
 end
 local function loopMessage() 
   for i = 1, 20 do
     trigger.action.outText('They are taking the Hobbits to Isengard', 2)
   end
    removeItem('Isengard')
 end 
 commandDB['Isengard'] = missionCommands.addCommand('Warning Message', nil, loopMessage)
Related Functions: missionCommands Functions: addCommand, addSubMenu, removeItem, addCommandForCoalition, addSubMenuForCoalition, removeItemForCoalition, addCommandForGroup, addSubMenuForGroup, removeItemForGroup
Notes: