Jump to content

How to set up toggle switches (a tutorial)


Recommended Posts

@epolta:

The original commands are ON/OFF toggles for use with push buttons. Eachtime you push the button the command toggles from ON to OFF or OFF to ON.

The following additions to "default.lua" provide 2-position ON/OFF commands for maintained ON/OFF switches:

{down = 3007, up = 3007, cockpit_device_id = 49 , value_down = 1.0, value_up = 0.0, name = _('Emergency Flood Light 2-Pos DAY/NIGHT'), category = _('Electrical power control panel')},
{down = 3001, up = 3001, cockpit_device_id = 1 , value_down = 1.0, value_up = 0.0, name = _('APU Gen Power 2-Pos ON/OFF'), category = _('Electrical power control panel')},
{down = 3004, up = 3004, cockpit_device_id = 1 , value_down = 1.0, value_up = 0.0, name = _('AC Gen Left Power 2-Pos ON/OFF'), category = _('Electrical power control panel')},
{down = 3005, up = 3005, cockpit_device_id = 1 , value_down = 1.0, value_up = 0.0, name = _('AC Gen Right Power 2-Pos ON/OFF'), category = _('Electrical power control panel')},
{down = 3006, up = 3006, cockpit_device_id = 1 , value_down = 1.0, value_up = 0.0, name = _('Battery Power 2-Pos ON/OFF'), category = _('Electrical power control panel')},

If you want to use a pair of push buttons for each of these commands then you have to split the command lines. Example for emergency flood light:

{down = 3007, cockpit_device_id = 49 , value_down = 1.0, name = _('Emergency Flood Light DAY'), category = _('Electrical power control panel')},
{down = 3007, cockpit_device_id = 49 , value_down = 0.0, name = _('Emergency Flood Light NIGHT'), category = _('Electrical power control panel')},

In the A-10C we need to use the numerical ID's for device and command. The cockpit_device_id number is found in the file "devices.lua".

The command ID is the button number from "clickabledata.lua plus 3000 (as found in "command_defs.lua")

Good luck!

Thanks a ton!

much appreciated!:thumbup:

Link to comment
Share on other sites

  • 2 weeks later...

Appreciate the assistance LeCuvier

 

Still struggling with a few, now on the Ka-50

 

We have a 2 pos toggle for the K-041 Targeting system, we built this command and placed it in the DCS World OpenBeta\Mods\aircraft\Ka-50\Cockpit\Scripts\default.lua file...

<code>{down = 3525, up = 3525, cockpit_device_id = 59 , valuedown = 1.0, valueup = 0.0, name = ('K041 Power 2pos'), category = ('Ins Targeting Mode Controls Panel PVR')},</code>

 

We sourced the number 3525 from 'command_defs.lua' "Plane_K041_Power = 525,"

 

We sourced the device from 'devices.lua' "devices["K041"] = 59"

 

When bound to the switch noting at all happens... any thoughts?

Any pointers on how i could become more self sufficient regarding that, don't want to be hassling you lot all the time, though i think the discussion has been pretty healthy and I've learned a bit !

 

Bonus question - I see "value_down = 1.0, value_up = 0.0" what are these numbers, and how are they determined?

R7 3800X - 32Gig RAM -- All SSD -- GTX1070 -- TM Warthog, MFG Crosswinds & TiR

Link to comment
Share on other sites

@v81: I don't mind helping; this keeps my knowledge up-to-date.

Please check the spelling in your code! "valuedown" and "valueup" are not valid. It needs to be "value_down" and "value_up".

value_down defines what happens when the contact closes, and value_up when the contact state changes from CLOSED to OPEN.

In order to understand what you are doing, read my tutorial earlier in this thread. If you don't find it let me know.

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

Hello guys before the new Update, i was able to setting airbrake like a toogle.

i've a X52 Pro.

 

With the category "Spécial for Hotas" > Action Retract/Off.

Now i'm forced to configure with 2 actions;

The first one :Air brake out with Joy_Button 7

The seconds : Air brake in with PINKIE + Button 7.

Is it possible to add in the default.lua a toggle command to do that Action Retract/Off.

Sorry for my bad English ;)

 

Thank you for the excellent work, and too for your answer. :-):helpsmilie:

Link to comment
Share on other sites

@kakal Ice: You can create a command EXTEND/RETRACT for use with a maintained 2-position switch. This code does it:

{down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS,value_down = -1.0,    value_up = 1.0,    name = _('Speed Brake 2-Pos Switch EXTEND/RETRACT'), category = {_('Throttle Grip'), _('HOTAS')}},

However, this will not allow you to set the speedbrake to an intermediate position.

In order to allow for intermediate positions you need 2 pushbuttons or a 3-position switch.

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

Hello how are you ?

I do that and it's doesn't work, what do you mean by a maintained 2-position switch ?

Is there a type of button on X52 Pro ?

 

 

 

I put the line like that: [ATTACH]194335[/ATTACH]

Thank you very much :(

The default.lua you posted is the one in the folder "keyboard". You need to make your additions to the file in the folder "joystick".

The command I created is designed for a switch that stays in the ON or OFF position, like a light switch. I have no idea what kind of switches you have on the X52. But if you want to use buttons that do not stay ON or OFF then you need 2 buttons and use the original commands from ED.

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

Has anyone else had their axis screwed up my modifying .lua?

 

I tweaked the F18 Master Arm, Speed Brake and Canopy Open/Close .lua and all the available axis were reduced to a bare minimum... eg one thrust, no L/R brakes etc plus about 20 others missing. (see pic). After undoing my changes, all the axis returned.

 

How is this avoided?

F18_Axis.png

Occulus Rift i7-7700 3.6Ghz 16GB Ram 1080Ti 11GB SSDx2

Link to comment
Share on other sites

Why wont this work for a F18 Speed Brake Toggle?? (hold switch = Brake extend, Release =Retract)

 

{ down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS, value_down = 1.0, value_up = 0.0, name = _('Speed Brake Switch - TOGGLE'), category = {_('Throttle Grip'), _('HOTAS')}},

Occulus Rift i7-7700 3.6Ghz 16GB Ram 1080Ti 11GB SSDx2

Link to comment
Share on other sites

Has anyone else had their axis screwed up my modifying .lua?

 

I tweaked the F18 Master Arm, Speed Brake and Canopy Open/Close .lua and all the available axis were reduced to a bare minimum... eg one thrust, no L/R brakes etc plus about 20 others missing. (see pic). After undoing my changes, all the axis returned.

 

How is this avoided?

I haven't seen your modified file so I can only guess: The "default.lua" consists of two blocks of code: First the switches and buttons, then the axes. The two blocks are separated by these lines:

})

-- joystick axes 
join(res.axisCommands,{

All additions for switches, pushbuttons etc must be before the "})". Maybe you have violated that rule?

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

Why wont this work for a F18 Speed Brake Toggle?? (hold switch = Brake extend, Release =Retract)

 

{ down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS, value_down = 1.0, value_up = 0.0, name = _('Speed Brake Switch - TOGGLE'), category = {_('Throttle Grip'), _('HOTAS')}},

For EXTEND you should use "value_down = -1.0" and for RETRACT "value_up = 1.0". The code you tried to use would only switch between RETRACT and OFF (which holds the current position)-

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

Hello grounders, in fact i don't know where place the line code,could you tell me or place exactly this line.

I know the path :C:\Program Files\Eagle Dynamics\DCS World OpenBeta\Mods\aircraft\FA-18C\Input\FA-18C\joystick

But exactly where i don't know.

If i send you my default .lua (default_original.lua)can you show me where put the line code:

 

 

 

{ down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS, value_down = 1.0, value_up = 0.0, name = _('Speed Brake Switch - TOGGLE'), category = {_('Throttle Grip'), _('HOTAS')}},

 

 

or this line code:

 

 

 

{down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS,value_down = -1.0, value_up = 1.0, name = _('Speed Brake 2-Pos Switch EXTEND/RETRACT'), category = {_('Throttle Grip'), _('HOTAS')}},

 

 

Thank you guys :pilotfly:

Link to comment
Share on other sites

@kakal Ice:

The file begins with these lines:

local cockpit = folder.."../../../Cockpit/Scripts/"
dofile(cockpit.."devices.lua")
dofile(cockpit.."command_defs.lua")

local res = external_profile("Config/Input/Aircrafts/common_joystick_binding.lua")

join(res.keyCommands,{

---------------------------------------------
-- Cheat ------------------------------------
---------------------------------------------

I recommend you insert your additions between these two lines:

join(res.keyCommands,{

---------------------------------------------

Your first line of code is almost right, but the values are wrong. It should be "... value_down = -1.0, value_up = 1.0 ..."

You can use this command with a push button or a maintained ON/OFF switch. When the contact closes, the speed brake will extend, and when the contact opens the speed brake will retract. You will not be able to extend the speed brake partially, because you have no OFF command.

 

PS: Use Notepad++ for editing .lua files!

Good luck!

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 thank you for having brought me an additional answer but i do that and he doesn't work.

What that is is normal that I cannot select the compartment keyboard it remains tinted? Perhaps it's for that no ?

Have a good day :)


Edited by kakal Ice
Forget
Link to comment
Share on other sites

Hi thank you for having brought me an additional answer but i do that and he doesn't work.

What that is is normal that I cannot select the compartment keyboard it remains tinted? Perhaps it's for that no ?

Have a good day :)

Are you saying that you want to use a keyboard button for the command? In that case you need to add the command to the default.lua in the "keyboard" folder.

You kept mentioning your X-52 stick and therefore I told you the command should be added in the file under "joystick".


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

  • 3 weeks later...

Is there any particular reason we can't put modified default.lua's in our Saved Games\DCS\Mods folder instead of base game directory?

My controls & seat

 

Main controls: , BRD-N v4 Flightstick (Kreml C5 controller), TM Warthog Throttle (Kreml F3 controller), BRD-F2 Restyling Bf-109 Pedals w. damper, TrackIR5, Gametrix KW-908 (integrated into RAV4 seat)

Stick grips:

Thrustmaster Warthog

Thrustmaster Cougar (x2)

Thrustmaster F-16 FLCS

BRD KG13

 

Standby controls:

BRD-M2 Mi-8 Pedals (Ruddermaster controller)

BRD-N v3 Flightstick w. exch. grip upgrade (Kreml C5 controller)

Thrustmaster Cougar Throttle

Pilot seat

 

 

Link to comment
Share on other sites

  • 2 weeks later...

How I can realize long press button in default.lua of Su-25A ?

I need momentary press button and generate long press button (~500ms) in DCS

 

these string let me realize only momentary press of the button...

{combos = {{key = '=', reformers = {'RShift'}}}, pressed = iCommandAltimeterPressureIncrease, up = iCommandAltimeterPressureStop, name = _('Altimeter Pressure Increase Su-25T'), category = _('Systems')},


Edited by jazzymanserg
Link to comment
Share on other sites

I suppose you want to generate a long (500 ms) key-press command from a very short physical signal (like from a rotary encoder). Unfortunately the FC3 aircrafts do not have a clickable cockpit and therefore no "clickabledata.lua".

Therefore I see no way to do this through .lua edits. With external software like TARGET it could be done.

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

  • 2 weeks later...
In order to understand what you are doing, read my tutorial earlier in this thread. If you don't find it let me know.

 

No luck finding that tutorial.

Searched the thread for all posts by you but still couldn't find it.

Maybe i missed it, would be great if you could link it.

Possibly even add it to your signature?

 

:edit:

Looking at setting up the Flaps switch on the Warthog Throttle for the SU-25T and SU-27

Would appear there is a command to toggle flaps up and down, and a command to set flaps to landing.

It appears i might be missing separate ability to have flaps in the up and mid positions.


Edited by v81

R7 3800X - 32Gig RAM -- All SSD -- GTX1070 -- TM Warthog, MFG Crosswinds & TiR

Link to comment
Share on other sites

No luck finding that tutorial.

Searched the thread for all posts by you but still couldn't find it.

Maybe i missed it, would be great if you could link it.

Possibly even add it to your signature?

Post #214 in this thread. For me that's on page 32

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...