Jump to content

Can't figure it out: attempt to index global 'missionCommands' (a nil value)


Recommended Posts

Posted

Hey, 

I keep getting the same error and I have (re)searched some examples but can't figure it out... (btw. my first attempt at LUA)

This is the code:

local RadioMenu = missionCommands.addSubMenu ('Training')
local Menu_A2A = missionCommands.addSubMenu ("Air to Air Training", RadioMenu)
local BFM_F5 = missionCommands.addCommand ("BFM F5", Menu_A2A)

and I keep getting "attempt to index global 'missionCommands' (a nil value)"

Anyone can help ? or have a link ? it is the part where it says "index global" 

I have added submenu's with the .addsubMenu (2 even 3 layers deep) but as soon as I reference the .addCommand I get the error.
Maybe someone can give some guidance as I am clueless now... 

Thanks in advance 

 

Spidierox

Posted

" local BFM_F5 = missionCommands.addCommand ("BFM F5", Menu_A2A) "

thers no command in that string, it should be ("BFM F5", Menu_A2A, COMMAND_FUNC)

you are try to add a command without set wich comand it have to call.

function COMMAND_FUNC()
..your script here..
end

Posted (edited)

local function Call_me ()
-- try  out
trigger.action.outText("F-5 spawned for BFM training!", 10)
end

local RadioMenu = missionCommands.addSubMenu ('Training')
local Menu_A2A = missionCommands.addSubMenu ("Air to Air Training", RadioMenu)
local BFM_F5 = missionCommands.addCommand ("BFM F5", Menu_A2A, Call_me)

 

Same problem "attempt to index global 'missionCommands' (a nil value)" --> this is my issue

Edited by spidierox
  • Recently Browsing   0 members

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