missionCommands#

missionCommands provides access to the F10 “Other” radio menu, letting scripts add commands and submenus that run Lua functions when selected, and remove them again later.

Functions#

missionCommands.addCommand(name, path, functionToRun, argument)#

Adds a command to the F10 “Other” menu, visible to all players, that calls functionToRun (with argument) when selected.

Parameters:
  • name (string) – Text displayed in the menu; also used to remove the command.

  • path (table) – Optional submenu path (as returned by addSubMenu()) to nest the command under. nil places it in the root menu.

  • functionToRun (function) – Function to call when the command is selected.

  • argument – Optional value passed to functionToRun.

Returns:

A path table indicating where in the F10 menu the command resides.

Return type:

table

Example:

local function displayMsg(vars)
    if vars.flyby 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')
missionCommands.addCommand('Negative Ghostrider', displayRequests, displayMsg, {flyby = false})
missionCommands.addCommand('Roger Ghostrider', displayRequests, displayMsg, {flyby = true})
missionCommands.addSubMenu(name, path)#

Creates a named submenu, visible to all players, optionally nested under another submenu.

Parameters:
  • name (string) – Submenu label.

  • path (table) – Optional parent submenu path. nil places it in the root menu.

Returns:

A path table identifying the new submenu.

Return type:

table

Example:

local requestMenu = missionCommands.addSubMenu('Request Asset')
missionCommands.addCommand('SEAD', requestMenu, doRequest, {type = 'SEAD'})
missionCommands.addCommand('CAS', requestMenu, doRequest, {type = 'CAS'})
missionCommands.removeItem(path)#

Removes the command or submenu (and everything nested within it) identified by path from the F10 menu for all players.

Parameters:

path (table) – Path returned by addCommand()/addSubMenu(), or nil to remove every item in the root menu.

missionCommands.addCommandForCoalition(coalitionId, name, path, functionToRun, argument)#

As addCommand(), but only visible to the given coalition.

Parameters:
  • coalitionId (number) – Coalition to add the command for (see coalition.side).

  • name (string) – Text displayed in the menu.

  • path (table) – Optional parent submenu path.

  • functionToRun (function) – Function to call when the command is selected.

  • argument – Optional value passed to functionToRun.

Returns:

A path table indicating where in the F10 menu the command resides.

Return type:

table

missionCommands.addSubMenuForCoalition(coalitionId, name, path)#

As addSubMenu(), but only visible to the given coalition.

Parameters:
  • coalitionId (number) – Coalition to add the submenu for.

  • name (string) – Submenu label.

  • path (table) – Optional parent submenu path.

Returns:

A path table identifying the new submenu.

Return type:

table

missionCommands.removeItemForCoalition(coalitionId, path)#

As removeItem(), scoped to a single coalition’s menu.

Parameters:
  • coalitionId (number) – Coalition the item was added for.

  • path (table) – Path to remove, or nil to clear the coalition’s root menu.

missionCommands.addCommandForGroup(groupId, name, path, functionToRun, argument)#

As addCommand(), but only visible to players in the given group.

Parameters:
  • groupId (number) – Group to add the command for.

  • name (string) – Text displayed in the menu.

  • path (table) – Optional parent submenu path.

  • functionToRun (function) – Function to call when the command is selected.

  • argument – Optional value passed to functionToRun.

Returns:

A path table indicating where in the F10 menu the command resides.

Return type:

table

missionCommands.addSubMenuForGroup(groupId, name, path)#

As addSubMenu(), but only visible to players in the given group.

Parameters:
  • groupId (number) – Group to add the submenu for.

  • name (string) – Submenu label.

  • path (table) – Optional parent submenu path.

Returns:

A path table identifying the new submenu.

Return type:

table

missionCommands.removeItemForGroup(groupId, path)#

As removeItem(), scoped to a single group’s menu.

Parameters:
  • groupId (number) – Group the item was added for.

  • path (table) – Path to remove, or nil to clear the group’s root menu.

Footnotes#

  • Functions that add commands/submenus return a “path” table, indexed numerically, that shows where in the F10 menu the entry resides, e.g. {[1] = "Command in Root"} or {[1] = "SubMenu", [2] = "Command in submenu"}.

  • Commands and submenus added without a coalition/group scope are visible to every player.