Difference between revisions of "DCS func removeItem"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
 
(One intermediate revision by the same user not shown)
Line 60: Line 60:
 
|related=  
 
|related=  
 
[[DCS_singleton_missionCommands|'''missionCommands Functions:''']] {{listOfMissionCommandFuncs}}
 
[[DCS_singleton_missionCommands|'''missionCommands Functions:''']] {{listOfMissionCommandFuncs}}
|notes=  
+
|notes= Not to be confused with [[DCS_func_removeItemWarehouse|Warehouse.removeItem]]
 
}}
 
}}
 
[[Category:Singleton Functions|removeItem]]
 
[[Category:Singleton Functions|removeItem]]
 +
[[Category:Game Patch 1.2.4|removeItem]]

Latest revision as of 18:13, 16 August 2023

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: Not to be confused with Warehouse.removeItem