Jump to content

GetDevice(device_id) in DO SCRIPT FILE


Go to solution Solved by cfrag,

Recommended Posts

Posted

New to LUA and DCS scripting and could use some assistance. I am trying to set up radio based flags for single-player AJS37 Viggen. Since there is not a cockpit parameter for the radio frequencies in that module, I have tried two alternatives:

1) checking the actual frequency tuned to each radio and then using some button-logic to determine which is active.
2) a system based on the buttons and rotary dial to determine the channel(s) that are active.

Unfortunately, both strategies rely on GetDevice(device_id), which I can't seem to get to run in the mission triggers. Am I approaching this incorrectly or is this not possible? Sure seems like it should be simple, but I'm beating my head against LUA errors here.

Example of where it goes wrong:
 

-- Define variables for device argument values
local FR24_MODE_VALUE = GetDevice(0):get_argument_value(386)
local FR22_GROUP_VALUE = GetDevice(0):get_argument_value(360)
local FR22_BASE_VALUE = GetDevice(0):get_argument_value(492)

-- Initialize flags
local FR24_MODE, FR22_GROUP, FR22_BASE, FR22_BUTTON, CHANNEL, GUARD


 

FR22 = GetDevice(30)
FR24 = GetDevice(31)

local FR22freq = FR22:get_frequency() -- full 9-digit frequency in hertz
local FR24freq = FR24:get_frequency() -- full 9-digit frequency in hertz


getdevice_error.gif

Warthog HOTAS, VMAX Prime Throttle, TPR pedals, Kensington Slimblade Pro,

Pimax Crystal, RTX 4090 FE, Asus ProArt X670E-Creator, Ryzen 7950X3D, 64gb DDR5.

Posted
4 hours ago, Pyrocumulous said:

both strategies rely on GetDevice(device_id)

What is that GetDevice() method? Can you perhaps link to its description? Is it perhaps part of a framework? I can't recall that method being part of the Mission Scripting Environment (MSE) - which may be the root cause of your issue

Posted

Perhaps it can't be done, this is my first attempt to use script, because doing this solely with ME triggers would get ridiculous in a hurry. This works in the LUA Console (DCS-Insight), though, so I thought that meant I could do it in a script.

In LUA Console, both of these examples return values:

  • return GetDevice(0):get_argument_value(492)  --returns value of FR22_BASE rotary knob
  • GetDevice(30):get_frequency()  --returns frequency of FR22 radio in hertz

Alternatively, in ME triggers, I can place:

  • X:COCKPIT ARGUMENT IN RANGE (492,0.005,0.015,"") --returns true if FR22 rotary knob is set to 01

I don't believe I can directly  access the frequencies of the Viggen radios with ME triggers, like can be done in the LUA console (or in modules with a cockpit parameter where one can use X:COCKPIT PARAM EQUAL TO("COMM2_FREQ","123.500"))

Warthog HOTAS, VMAX Prime Throttle, TPR pedals, Kensington Slimblade Pro,

Pimax Crystal, RTX 4090 FE, Asus ProArt X670E-Creator, Ryzen 7950X3D, 64gb DDR5.

  • Solution
Posted (edited)
20 hours ago, Pyrocumulous said:

This works in the LUA Console

Ah. Make sure that you try this in the "mission" environment in the console first. It is well possible that GetDevice() is only avialable for the "export" environment

 

Edited by cfrag
  • Thanks 1
Posted

Good info, thanks. It is my understanding that the mission LUA console is locked down in public releases.  Is there another way to access the mission environment besides simply placing the LUA code in a mission editor trigger?

Warthog HOTAS, VMAX Prime Throttle, TPR pedals, Kensington Slimblade Pro,

Pimax Crystal, RTX 4090 FE, Asus ProArt X670E-Creator, Ryzen 7950X3D, 64gb DDR5.

Posted
56 minutes ago, Pyrocumulous said:

Is there another way to access the mission environment besides simply placing the LUA code in a mission editor trigger?

There is one way, but it is currently limited to reading and setting flags. Network's doString_in() is set up generally to execute in other environments, but at this point in time, it only executes the methods that read and write mission flags,

  • Like 1
  • Recently Browsing   0 members

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