Difference between revisions of "DCS func addCommand"

From DCS World Wiki - Hoggitworld.com
 
(4 intermediate revisions by 2 users not shown)
Line 61: Line 61:
 
The sample below will generate a base menu accessed via F10 called "Display Requests" for all users with two sub-items for a negative or positive response
 
The sample below will generate a base menu accessed via F10 called "Display Requests" for all users with two sub-items for a negative or positive response
  
 
+
  local function displayMsg(vars)
local displayRequests = missionCommands.addSubMenu( "Display Requests")
+
      if vars.flyby == true then
local negativeReply = missionCommands.addCommand( "Negative Ghostrider", displayRequests , displayMsg, {flyby = false})
+
          trigger.action.outText("Roger that Ghostrider, you may do a flyby.", 20)
local positiveReply = missionCommands.addCommand( "Roger Ghostrider", displayRequests , displayMsg, {flyby = true})
+
      else
 +
          trigger.action.outText("Negative Ghostrider, the pattern is full", 20)
 +
      end
 +
  end
 +
  local displayRequests = missionCommands.addSubMenu( "Display Requests")
 +
  local negativeReply = missionCommands.addCommand( "Negative Ghostrider", displayRequests , displayMsg, {flyby = false})
 +
  local positiveReply = missionCommands.addCommand( "Roger Ghostrider", displayRequests , displayMsg, {flyby = true})
  
  
Line 72: Line 78:
 
}}
 
}}
 
[[Category:Singleton Functions|addCommand]]
 
[[Category:Singleton Functions|addCommand]]
 +
[[Category:Game Patch 1.2.4|addCommand]]

Latest revision as of 23:02, 5 September 2024

Scripting Root

Envrioment: Mission Scripting
Function: addCommand Added with: 1.2.4
Member Of: missionCommands
Syntax: table missionCommands.addCommand(string name , table/nil path , function functionToRun , any anyArguement)
Description: Adds a command to the "F10 Other" radio menu allowing players to run specified scripting functions. Command is added for both teams. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.

Path is an optional value that defines whether or not the command will be in a named submenu.

FunctionToCall is the name of the function, with the optional argument value designating any passed values.


Return Value: table
Return Example: Function returns a table indexed numerically indicating where in the F10 menu the command resides.
 {
   [1] = "Negative Ghostrider",
 }
 {
   [1] = "SubMenuInRoot", 
   [2] = "Command in the submenu",
 }
 { 
   [1] = "SubMenuInRoot", 
   [2] = "SubMenuInSubMenu", 
   [3] = "Command in nested submenu",
 }
Examples: The sample below will generate a base menu accessed via F10 called "Display Requests" for all users with two sub-items for a negative or positive response
 local function displayMsg(vars)
     if vars.flyby == true then
         trigger.action.outText("Roger that Ghostrider, you may do a flyby.", 20)
     else
         trigger.action.outText("Negative Ghostrider, the pattern is full", 20)
     end
 end
 local displayRequests = missionCommands.addSubMenu( "Display Requests")
 local negativeReply = missionCommands.addCommand( "Negative Ghostrider", displayRequests , displayMsg, {flyby = false})
 local positiveReply = missionCommands.addCommand( "Roger Ghostrider", displayRequests , displayMsg, {flyby = true})
Related Functions: missionCommands Functions: addCommand, addSubMenu, removeItem, addCommandForCoalition, addSubMenuForCoalition, removeItemForCoalition, addCommandForGroup, addSubMenuForGroup, removeItemForGroup
Notes: