Jump to content

Path parameter does not seem to work in missionCommands.addCommandForCoalition


DackSter94

Recommended Posts

Hello.

 

I can't get my radiocommand inside created radio submenu. Submenu is created but the command goes into the root of f10 menu. What could be the problem?

 

Here is code example:

--Functions to set user flags to "true"
local function SUFT500()
trigger.action.setUserFlag('500',1)
end

[b]--Adding 'Support' Submenu
missionCommands.addSubMenu('Support')

--Adding Blue Radio Commands to 'Support' Submenu
missionCommands.addCommandForCoalition(coalition.side.BLUE,'Start E-3A AWACS','Support',SUFT500,nil)[/b]

 

PS: Already tryed to create Support submenu separatly for each coalition with addSubMenuForCoalition, which didn't work as well.


Edited by DackSter94

LOOK MA, NO HOOK

Link to comment
Share on other sites

Your formatting is wrong because the path of the submenu isn't defined as a string, but as a table. Which you can get when you create the submenu.

 

See the wiki

 

local supMenu= missionCommands.addSubMenu('Support')
missionCommands.addCommandForCoalition(coalition.side.BLUE,'Start E-3A AWACS', supMenu ,SUFT500,nil)

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Your formatting is wrong because the path of the submenu isn't defined as a string, but as a table. Which you can get when you create the submenu.

 

See the wiki

 

local supMenu= missionCommands.addSubMenu('Support')
missionCommands.addCommandForCoalition(coalition.side.BLUE,'Start E-3A AWACS', supMenu ,SUFT500,nil)

 

Thanks!!

 

What about addCommand? Seems like you can make it table as well, but works without it.

Also do you know the syntax for removeItem to remove a radio command inside a submenu? There is no examples for removeItem on wiki :(


Edited by DackSter94

LOOK MA, NO HOOK

Link to comment
Share on other sites

Yeah they all follow the same logic of returning a path. Said path can be used to remove menu items as desired. Its more a question of how you want to keep track of the menus and add/remove them. For example in On Station Classic I created a little voting script with the F10 commands. Instead of saving each vote selection I just saved the submenu for it. So whenever the voting ends it just points to the path for the submenus related to voting and removes those.

 

 

Edit;

 

Added an example to remove item to the wiki. I however realized I forgot to answer your question more directly here...

 

If you know the names of the menus then it is relatively easy to create the correct syntax. The example I added on the wiki is more of a simplified way of doing it by saving the path into table that is referenced by a name or number and then have another function look in the table for that index and removing it that way.

 

Simply because you know the names of the menu items you could use the following to create the submenu and the AWACs command.

missionCommands.addSubMenu('Support')
missionCommands.addCommand('Start E-3A AWACS'', {[1] = 'Support'}, SUFT500)

And to remove it...

missionCommands.removeItem({[1] = 'Support', [2] = 'Start E-3A AWACS'})


Edited by Grimes

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...