Jump to content

Recommended Posts

Posted

Hi all, seasoned coder since 35+ years but a newb to LUA and DCS scripting. For my current hobby project I need to get the state of cockpit switches (external lights) and my "research" has lead me to understand I need the GetDevice() function. However, when I use that function in my own .lua file I get this in the log ...

attempt to call global 'GetDevice' (a nil value)

... implying GetDevice is not available. What do I need to do to enable it? My .lua file was loaded on the MISSION START event, after MOOSE and MIST libraries.

Thanks

 

i7-3930K CPU @ 3.20GHz; 16Gb DDR3; GeForce GTX 1070; Windows 10; TM Warthog HOTAS

Posted

Hi!

I am also playing with LUA scripts of DCS for my project that exports the devices, controls and their values and IDs. I belive, that you need to pass the parameter, number of the devise as it can be seen in other modules.

Example given: 

local ale39 = data.base.GetDevice(5)

 

Also each module contains script called devices.lua. This LUA script contains list of all devices, their names and indexes.

Posted
10 hours ago, ShadowDragonCZ said:

Hi!

I am also playing with LUA scripts of DCS for my project that exports the devices, controls and their values and IDs. I belive, that you need to pass the parameter, number of the devise as it can be seen in other modules.

Example given: 

local ale39 = data.base.GetDevice(5)

 

Also each module contains script called devices.lua. This LUA script contains list of all devices, their names and indexes.

Thanks, but the problem is the lua context doesn't recognize the GetDevice() method. My question was how to enable it.

Do you have an example on how you set up your export to enable device querying?

i7-3930K CPU @ 3.20GHz; 16Gb DDR3; GeForce GTX 1070; Windows 10; TM Warthog HOTAS

Posted
On 8/16/2022 at 8:41 AM, moggel said:

Thanks, but the problem is the lua context doesn't recognize the GetDevice() method. My question was how to enable it.

Do you have an example on how you set up your export to enable device querying?

Oh, that's something different, yes. I have tried searching all the LUA scripts in the game folder for declaration of tis LUA function and haven't found anything. I am affraid that this method is somewhere in DCS binaries and not available to us, but only as part of SDK. I might be wrong, but wasn't able to find it.

  • 7 months later...
Posted

For posterity, in case other people run into this as well:

I've been struggling with this as well when I converted a mod to use the new Hooks approach instead of the old Export script approach.

GetDevice() is available in the Export namespace, so Export.GetDevice() should do what you want

  • Recently Browsing   0 members

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