Jump to content

Recommended Posts

Posted

greetings,

I am trying to write an F10 radio menu item to initialize a CTLD JTAC:

local subR1 = missionCommands.addSubMenu('Root SubMenu')
local subN1 = missionCommands.addCommand('JTAC Activate', subR1, ctld.JTACAutoLase, { 'JTAC1', 1688 })

The above adds a radio menu command, but when i select it, the JTAC does not activate, and i see the following error in my DCS.log:

ERROR   SCRIPTING (Main): [string "C:\Users\SHURUG~1.DRA\AppData\Local\Temp\DCS.openbeta/~mis00003F1D.lua"]:5996: Parameter #1 (group name) missed

when i open that temp file and navigate to the relevant line, i find the CTLD command i want, which makes me think that the parameters/arguments are not being passed:

function ctld.JTACAutoLase(_jtacGroupName, _laserCode, _smoke, _lock, _colour, _radio)

 

 

When i use a trigger command 'do script' in the mission editor to call:

ctld.JTACAutoLase('JTAC1', 1688)

the JTAC activates as expected.

 

I'm sure i'm doing something wrong, but i have no idea what.

test1.miz

  • 3 weeks later...
Posted

Let's check the documentation:
 

missionCommands.addCommand(string name , table/nil path , function functionToRun , any anyArgument)

Let's compare this to your implementation of the addCommand function:
 

local subN1 = missionCommands.addCommand('JTAC Activate', subR1, ctld.JTACAutoLase, { 'JTAC1', 1688 })


The problem seems to be that you are trying to pass a single table argument for "any anyArgument" rather than a string and a number.


Try this:
 

local subN1 = missionCommands.addCommand('JTAC Activate', subR1, ctld.JTACAutoLase, 'JTAC1', 1688)
Posted

It doesn't automatically unpack any table passed to a function. Generally its a good idea to create a wrapper function that will then manipulate the values passed and call the expected function. Basically add ctld.JTACAutoLase to the values passed in the table and create another function that then calls ctld.JTACAutoLase with the other parameters.

 

Though you could try: 

local subN1 = missionCommands.addCommand('JTAC Activate', subR1, ctld.JTACAutoLase, unpack({ 'JTAC1', 1688 }))

 

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

  • Recently Browsing   0 members

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