Jump to content

How to set up toggle switches (a tutorial)


Recommended Posts

First of all, thanks guys for the useful documentation on how to setup switches. Now I'm fine tuning my setup the perfect way.

 

And so, now I'm using it, I got a question: How to you ensure DCS update do not erase your setup? As we are modifying the .lua in mods planes, I assume that any update will erase them. I didn't find nothing about it in the doc.

 

Today I manually, copy/paste for each setup the new lines in a file, and copy/paste back in default.lua for the plane when tehre is an update, but it can lead to mistakes. Any solution?

Link to comment
Share on other sites

Make your modifications as mod packages that you'll apply using OvGME.

I've got a document explaining how-to, but in french ^^

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

OvGME has an excellent help structure built in (in English in my installation). But where can people get the setup .exe? Since Sedenion stopped supporting the package, the install has disappeared from his original post. I still have the ovgme_1_7_4_setup_64.exe on my computer but I'm not sure I'm allowed to share it.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

Hi,

I used to be able to find my way through some code, but getting old and feeling stupid. I can not make sense of this stuff anymore and can not figure out which files to use with C-101 to even try these fixes. Everything I have tried has broke DCS inputs in one way or another. Can you help an old fart out? I have tried adding the up settings for the off positions for 2 and 3 way toggles, but am either misunderstanding the how or where...

 

Thanks,

Salute

Punk

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hi,

...I have tried adding the up settings for the off positions for 2 and 3 way toggles, but am either misunderstanding the how or where...

...

I do not have the C101 module. But if you describe your issue specifically with examples of the code you are trying to modify I might be able to help. I might also need the original "default.lua" in order to see what's in the file.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I do not have the C101 module. But if you describe your issue specifically with examples of the code you are trying to modify I might be able to help. I might also need the original "default.lua" in order to see what's in the file.

Okay, I have confused myself even more trying to lay this out so I am probably way off here.

1st example is from f>ob<mods>ac>c101>input>c101eb>joystick>default.lua

 

Extract for battery switch:

--Batteries

{down = device_commands.Button_1,cockpit_device_id = 2, value_down = 1.0, name = _('Battery master switch - ON'),category = {_('Main instrument panel')}},

{down = device_commands.Button_1,cockpit_device_id = 2, value_down = 0.0, name = _('Battery master switch - OFF'), category = {_('Main instrument panel')}},

 

 

But when I go to c>game>saved games>ob>config>input>c101>Throttle - HOTAS Warthog {06B75280-1861-11e5-8002-444553540000}.diff I get this...

 

Extract for battery switch:

["name"] = "Battery master switch - ON",

},

["d3003pnilu3003cd2vd1vpnilvu0"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN31",

 

When I tried defining an up state for the switch in the default.lua, DCS inputs were all messed up. Was I even in the ball park or am I simply misunderstanding the files I am to look up and how to insert the up command? If you need the entire default.lua or another let me know and I will attach it.

 

Thanks,

Salute

Punk

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

tks! :thumbup: How do I configure it to add some line in default.lua (for F18 for example). I know how to replace a file, not how to merge.

To make adds/edits to the .lua file use the fre program Notepad++

But before trying to do that, make sure you go through the tutorial I posted under post #214!

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

@punk: any customization should be in the "default.lua". Do not mess with the .diff.lua files under "Saved Games"! These latter files record the bindings you have added or deleted and must not be edited manually!

I suspect you want to create a command for use with a maintained ON/OFF switch, so you can switch the battery ON and OFF with a single switch. By the way, most of my mods are of that nature. In order to do that you add this line to the "default.lua":

{down = device_commands.Button_1, up = device_commands.Button_1, cockpit_device_id = 2,    value_down =  1.0, value_up =  1.0,    name = _('Battery master switch - 2-Pos ON/OFF'),category = {_('Main  instrument panel')}},
 

So you combine the two original commands into one new command. The new command MUST have a distinct name. Don't forget the comma at the end of the line! And make sure the line is added inside the block of switch commands (see my tutorial!).

After creating the new command you need to bind it to a switch in Options/Commands.

Note: DCS World reads the .lua files when it starts up. Any changes you make while the program is running are ignored. Therefore it's best to exit from the program before editing .lua files.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I suspect you want to create a command for use with a maintained ON/OFF switch, so you can switch the battery ON and OFF with a single switch.

So you combine the two original commands into one new command. The new command MUST have a distinct name. Don't forget the comma at the end of the line! And make sure the line is added inside the block of switch commands (see my tutorial!).

After creating the new command you need to bind it to a switch in Options/Commands.

 

Thanks for your help, Sir. Yes, your suspicion is correct. Will this work for ON/OFF/ON switches as well or will it be a different animal? There are many of these types of switches as well of coarse. Again, thanks for your help.

 

Salute :punk:

 

ps. I was just looking this over as I started editing the lua and is it correct that value_down and value_up will use the same value?

 

"value_down = 1.0, value_up = 1.0,"

 

I thought your tutorial said to use the second value of the original, ie. 0.0 for value_up in this case... that must be where I was misunderstanding things the most.


Edited by punk

Punk

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

I‘m french too. donc si tu as un lien je prends !

Ici : https://docs.google.com/document/d/1fV9UQBjxZuvVEG8kueDSqthmOpHzYsf5QB_1oxuLJ60

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

ps. I was just looking this over as I started editing the lua and is it correct that value_down and value_up will use the same value?

 

"value_down = 1.0, value_up = 1.0,"

 

I thought your tutorial said to use the second value of the original, ie. 0.0 for value_up in this case... that must be where I was misunderstanding things the most.

I was just testing you and you pass! :) No, in reality it was my oversight. I was a bit in a hurry and yes, of course it should be value_up = 0.0

 

 

Regarding 3-position switches it's the same logic but you need two lines of code, like for a flaps switch with the positions Flight/Takeoff/Land.

Here is a command I added to the Mig-21 for Radar ON/Standby/OFF:

{down=device_commands.RADARon,up=device_commands.RADARon,cockpit_device_id=devices.RADAR,value_down=1,value_up=0.5,name='Radar 3-Pos ON/STBY',category='Radar and SPO'},
{down=device_commands.RADARon,up=device_commands.RADARon,cockpit_device_id=devices.RADAR,value_down=0,value_up=0.5,name='Radar 3-Pos OFF/STBY',category='Radar and SPO'},

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I was just testing you and you pass! :) No, in reality it was my oversight. I was a bit in a hurry and yes, of course it should be value_up = 0.0

 

 

Regarding 3-position switches it's the same logic but you need two lines of code, like for a flaps switch with the positions Flight/Takeoff/Land.

Here is a command I added to the Mig-21 for Radar ON/Standby/OFF:

{down=device_commands.RADARon,up=device_commands.RADARon,cockpit_device_id=devices.RADAR,value_down=1,value_up=0.5,name='Radar 3-Pos ON/STBY',category='Radar and SPO'},
{down=device_commands.RADARon,up=device_commands.RADARon,cockpit_device_id=devices.RADAR,value_down=0,value_up=0.5,name='Radar 3-Pos OFF/STBY',category='Radar and SPO'},

:thumbup:

 

Thanks again.

 

Salute.

:punk:

 

ps. Hmm, I seem to still be missing something. None of the changes have added any extra choices. I have to assume I am editing the wrong file:

F:\DCS World OpenBeta\Mods\aircraft\C-101\Input\C-101EB\joystick\default.lua.

 

Example of change in case my head is up my posterior again:

--Generator added code 032620
{down = device_commands.Button_10, cockpit_device_id = 2,   value_down = -1.0,  name = _('Generator - RESET'), category = _('Main instrument panel')},
{down = device_commands.Button_10,cockpit_device_id = 2,    value_down = 0.0,    name = _('Generator - OFF'),        category = {_('Main instrument panel')}},
{down = device_commands.Button_10,cockpit_device_id = 2,    value_down = 1.0,    name = _('Generator - ON'),    category = {_('Main instrument panel')}},
{down = device_commands.Button_10, up = device_commands.Button_10, cockpit_device_id = 2,value_down = -1.0, value_up = 0.0, name = _('Generator - 2-Pos RESET/OFF'), category = _('Main instrument panel')},
{down = device_commands.Button_10, up = device_commands.Button_10, cockpit_device_id = 2,value_down = 1.0, value_up = 0.0, name = _('Generator - 2-Pos ON/OFF'), category = _('Main instrument panel')},


Edited by punk

Punk

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

ps. Hmm, I seem to still be missing something. None of the changes have added any extra choices. I have to assume I am editing the wrong file:

F:\DCS World OpenBeta\Mods\aircraft\C-101\Input\C-101EB\joystick\default.lua.

 

Example of change in case my head is up my posterior again:

--Generator added code 032620
{down = device_commands.Button_10, cockpit_device_id = 2,   value_down = -1.0,  name = _('Generator - RESET'), category = _('Main instrument panel')},
{down = device_commands.Button_10,cockpit_device_id = 2,    value_down = 0.0,    name = _('Generator - OFF'),        category = {_('Main instrument panel')}},
{down = device_commands.Button_10,cockpit_device_id = 2,    value_down = 1.0,    name = _('Generator - ON'),    category = {_('Main instrument panel')}},
{down = device_commands.Button_10, up = device_commands.Button_10, cockpit_device_id = 2,value_down = -1.0, value_up = 0.0, name = _('Generator - 2-Pos RESET/OFF'), category = _('Main instrument panel')},
{down = device_commands.Button_10, up = device_commands.Button_10, cockpit_device_id = 2,value_down = 1.0, value_up = 0.0, name = _('Generator - 2-Pos ON/OFF'), category = _('Main instrument panel')},

If you have installed your DCS World on the disk drive F: then that's the right file to edit.

I assume the first 3 lines are the original .lua code, and you added the 4th and 5th lines just underneath. Correct?

I note one inconsistency: In lines 2 and 3 the syntax of the "category" part is different from that in lines 1, 4 and 5.

In lines 2 and 3 it's "category = {_('Main instrument panel')}" and in the other lines it's "category = _('Main instrument panel')" (without the curly braces). I'm not sure if that's the problem but it might. Have a look at the other lines in the original file. If the category part is always enclosed by curly braces ({ }) then your added lines should follow the same syntax.

This is a bit frustrating. If had the C-101 and the original file I could figure it out very quickly, but I'm not buying that module. If you could post the original and the modified file that would probably help.

Another thing to check: some modules have not just the "default.lua" but also equivalent files for other game controllers. File names are like "Throttle - HOTAS Warthog.lua" or "Joystick - HOTAS Warthog.lua". If there are such files and you have the corresponding game controller, then you must add your modifications to those files to make the added commands show.

Ignore files ending with "diff.lua"!

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

This is a bit frustrating.

Another thing to check: some modules have not just the "default.lua" but also equivalent files for other game controllers.

Ignore files ending with "diff.lua"!

 

Sorry, I was hoping not to be that guy.

 

Secondly, no other files except for my rudders, CH PRO PEDALS USB, file.

 

I will post the files when I get a chance.

 

Thanks for all your help. Your time and efforts are greatly appreciated.

 

ps: seems to be working now, will test it and get back. Attaching files, FYI and others. Again, thanks.

default old.lua

default.lua


Edited by punk

Punk

 

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 weeks later...

F-16 AutoPilot troubles

 

I was trying to get my old X Keys box working in the Viper. Finally got back around to it and worked through a few of the problems and got to the point that I was satisfied that the X Keys is working. The key strokes are making it to DCS as they should.

 

But the one last Pitch Auto Pilot switch would not work. I would return to the center off position but would not move in either direction. So I figured since the one position (A/P OFF) worked I should have a look at the lua and see why it's different. The ALT Hold & ATT Hold both had Down and Up values. So I figured what the hell. I took out the Up part and renamed it. And presto one happy camper. Don't know why it worked because I am a newbie with all this.

But !!! Did the update. Replaced the lua with my modded version. And Im back to not working. Looks like a lot of changes in that default lua. So I put the updated lua back in and then cut and pasted my two lines of code.

The new code shows up in the game but I can not select them to add the keystroke to it. It is "greyed out".

-- MISC Panel
--Edited April 5 2020   Removed the Up = parts of both
{    down = control_commands.ApPitchAtt,                                                                cockpit_device_id = devices.CONTROL_INTERFACE,    value_down = -1.0,        name = _('Autopilot PITCH Switch - Down Menessis'),            category = {_('Instrument Panel'), _('FLCS')}},
{    down = control_commands.ApPitchAlt,                                                                cockpit_device_id = devices.CONTROL_INTERFACE,    value_down =  1.0,                      name = _('Autopilot PITCH Switch - Up Menessis'),            category = {_('Instrument Panel'), _('FLCS')}},
--
{    down = control_commands.ApPitchAlt,                up = control_commands.ApPitchAlt,                cockpit_device_id = devices.CONTROL_INTERFACE,    value_down =  1.0,    value_up = 0.0,    name = _('Autopilot PITCH Switch - Up'),            category = {_('Instrument Panel'), _('FLCS')}},
{    down = control_commands.ApPitchAtt,                up = control_commands.ApPitchAtt,                cockpit_device_id = devices.CONTROL_INTERFACE,    value_down = -1.0,    value_up = 0.0,    name = _('Autopilot PITCH Switch - Down'),            category = {_('Instrument Panel'), _('FLCS')}},
{


So any thoughts out there?


Menessis


Edited by Menessis
Link to comment
Share on other sites

@Menessis: Your first two lines of code are "amputated". As far as I understand they need the "up" part to work with a pair of pushbuttons for moving the 3-position switch up or down.

The last 2 lines look like the original code.

I implemented the 3-position switch for use with the AP switch on my TM Warthog throttle:

{down = control_commands.ApPitchAlt_EXT, up = control_commands.ApPitchAlt_EXT, cockpit_device_id = devices.CONTROL_INTERFACE, value_down =  1.0, value_up = -1.0,    name = _('Autopilot PITCH Switch ALT HOLD/OFF'), category = {_('Instrument Panel'), _('FLCS')}},
{down = control_commands.ApPitchAtt_EXT, up = control_commands.ApPitchAlt_EXT, cockpit_device_id = devices.CONTROL_INTERFACE, value_down = -1.0,    value_up = -1.0, name = _('Autopilot PITCH Switch ATT HOLD/OFF'), category = {_('Instrument Panel'), _('FLCS')}},

In summary: If you want to use a maintained 3-position switch, use my code. If you want to use a pair of push buttons or a up/down toggle with spring return to center, use the original Up/Down commands.


Edited by LeCuvier

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

Hi LeCuvier. Yes they are shortened. I took out the up part. They didn't work with it in before.

 

The X Keys is running software that I have set up to generate the key presses up and down. So I flip a switch to the on position and the X Keys sends an key press and a key release (key down and up).

Then I have to go in the game and set the same key for that function.

 

That part all works fine. I can flip switches and watch the DCS setup screen and each one is hi lighted in turn. But does not work in the sim. So that means it's down to the lua.

 

 

Do you see what I am talking about now?

 

 

Thanks

Menessis

Link to comment
Share on other sites

Hi LeCuvier. Yes they are shortened. I took out the up part. They didn't work with it in before.

 

The X Keys is running software that I have set up to generate the key presses up and down. So I flip a switch to the on position and the X Keys sends an key press and a key release (key down and up).

Then I have to go in the game and set the same key for that function.

 

That part all works fine. I can flip switches and watch the DCS setup screen and each one is hi lighted in turn. But does not work in the sim. So that means it's down to the lua.

 

 

Do you see what I am talking about now?

 

 

Thanks

Menessis

I think I understand what you are saying. But the Pitch Autopilot switch is a 3-position switch with 3 stable positions. How do you intend to configure your set-up to achieve 3 stable positions?

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

In summary: If you want to use a maintained 3-position switch, use my code. If you want to use a pair of push buttons or a up/down toggle with spring return to center, use the original Up/Down commands.

 

Hello LeCuvier,

 

Is there a typo in your configuration or is it normal that the second line refers to the ApPitchATt_EXT instead of ApPitchALt_EXT?

 

 

UHGKbFV.jpg

 

 

I'm not sure I understand this configuration, but I think it may be intentional ?


Edited by davidp57

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

Hello LeCuvier,

 

Is there a typo in your configuration or is it normal that the second line refers to the ApPitchATt_EXT instead of ApPitchALt_EXT?

 

 

UHGKbFV.jpg

 

 

I'm not sure I understand this configuration, but I think it may be intentional ?

It's intentional. The stock file has these 3 lines for use with 3 push buttons.

 

{    down = control_commands.ApPitchAlt_EXT,            up = control_commands.ApPitchAlt_EXT,            cockpit_device_id = devices.CONTROL_INTERFACE,    value_down =  1.0,    value_up = 0.0,    name = _('Autopilot PITCH Switch - ALT HOLD'),        category = {_('Instrument Panel'), _('FLCS')}},
{    down = control_commands.ApPitchAlt_EXT,                                                            cockpit_device_id = devices.CONTROL_INTERFACE,    value_down = -1.0,                    name = _('Autopilot PITCH Switch - A/P OFF'),        category = {_('Instrument Panel'), _('FLCS')}},
{    down = control_commands.ApPitchAtt_EXT,            up = control_commands.ApPitchAtt_EXT,            cockpit_device_id = devices.CONTROL_INTERFACE,    value_down = -1.0,    value_up = 0.0,    name = _('Autopilot PITCH Switch - ATT HOLD'),        category = {_('Instrument Panel'), _('FLCS')}},

I combined them into 2 lines for a 3-position switch with the positions Attitude Hold/Off/Altitude Hold.

With this code the switch works fine, but I have a feeling that the AP as such doesn't do much. But maybe I need to RTFM.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

LeCuvier :) The X Keys generates a key press down and a key press release when I flip the switch up. So In my case i used a "u". But at the same time it is programmed that when I return that switch to the off position it generates a key press down and a key press release (or up). In my case a "v".

 

And in DCS I have to put the "u" in for Alt Hold and the "v" in for A/P Off.

 

But the way the lua file is now there is a key stroke for A/P Off but not for Up or Down. Remember that the X Key board is not direct x and therefore does not show as a controller in DCS. DCS doesn't know it exists. DCS is just getting key strokes from the X Keys.

 

 

The Roll switch works. So maybe I should compare the two and see if I can figure it out that way.

 

 

 

Menessis

Link to comment
Share on other sites

LeCuvier :) The X Keys generates a key press down and a key press release when I flip the switch up. So In my case i used a "u". But at the same time it is programmed that when I return that switch to the off position it generates a key press down and a key press release (or up). In my case a "v".

And in DCS I have to put the "u" in for Alt Hold and the "v" in for A/P Off.

But the way the lua file is now there is a key stroke for A/P Off but not for Up or Down. Remember that the X Key board is not direct x and therefore does not show as a controller in DCS. DCS doesn't know it exists. DCS is just getting key strokes from the X Keys.

The Roll switch works. So maybe I should compare the two and see if I can figure it out that way.

Menessis

I have checked the bindings and they are all there. But you seem to be mixing things up. There are two possibilities:

1. You use the UP and DOWN commands to move the switch through its 3 positions. I tried this with the bindings shown in the attachmant and it works just fine.

2. You use the 3 commands to set the absolute switch positions Att, Alt and Off.

Do not make a mix of the 2 methods! There is no need to modify .lua files.

311506999_F-16PitchAP.thumb.jpg.b8dc34cbfc823c200e36499d60f3eba5.jpg

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

  • Recently Browsing   0 members

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