Jump to content

performClickableAction MIG 21


Recommended Posts

Hello,

 

I'm in process of learning and experimenting interfacing with DCS through LUA scripts.

I have read tons of great posts on this sub forum regarding that matter.

However I'm encountering the problems with MIG 21 clickable buttons.

 

i.e. RSBN button on right vertical panel.

 

I have followed this logic to performClickableAction against that button:

 

1. find device that holds RSBN DEVICES.LUA line 33 = devices["RSBN"] = counter() --28

2. find button and parameters clickabledata.lua - line 371

elements["PNT_176"] = default_2_position_tumb(LOCALIZE("RSBN On/Off"),
devices.RSBN
,
device_commands.RSBNon
,176)

device = 28, command = 3054 - start_command = 3000 - RSBNon = start_command + 54;

3. find parameters

RSBN_switch = CreateGauge("parameter")

RSBN_switch.parameter_name = "RSBN_switch"

RSBN_switch.arg_number = 176

RSBN_switch.input = { 0, 1 }

RSBN_switch.output = { 0, 1 }

I suppose 1 is for ON 0 for OFF

 

in my LUA script I do following

 

local RSBN = GetDevice(28)
RSBN:performClickableAction(3054, 1)

 

But button remains OFF - I'm going nuts here. Some buttons do follow the logic but almost all buttons on RV panel are non responsive.

 

Can you please point me what is wrong in this approach ?

 

many thanks

Mirko

Link to comment
Share on other sites

  • 1 month later...

I had the same problem earlier, but I found out the the GetDevice() function is not always correct. Devices with higher ID are not correct at all.

Try the following:

local RSBN = GetDevice(25)

RSBN:performClickableAction(3054, 1)

I checked it and it's working.

Peter

Link to comment
Share on other sites

(Note: I don't have the Mig-21)

 

Take a close look at the devices.lua file. The ID in the comment does not have to be correct! (Look for places where the ID in the comment skips over a number...)

 

Each time the counter() function is called, it will return the next ID. So start with the first device ID and count from there.

 

The comments were probably correct at some point in time and then they removed one or more lines from the middle somewhere.

 

The devices.lua for the UH-1H has the same kind of inconsistency.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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