Clickabledata

From EagleWiki

Jump to: navigation, search

Clickabledata.lua One of the main script files for the DCS cockpit module. It is located in the folder Ka-50\Scripts\Aircrafts\Ka-50\Cockpit\

This script file contains definitions of clickable elements of the cockpit

Understanding element definition

(Here we are using the definition of the Master Arm switch element as an example)

elements["MASTER-ARM-PTR"] = {
   class = {class_type.TUMB, class_type.TUMB},
   hint = LOCALIZE("Master Arm"),  
   device = devices.WEAP_INTERFACE,
   action = {device_commands.Button_1,device_commands.Button_1},
   stop_action = {},
   arg = {387,387},
   arg_value = {-1.0,1.0},
   arg_lim = {{0.0, 1.0},{0.0, 1.0}}, 
   use_OBB = true, 
   updatable = true
}

This creates a clickable element connected to a cockpit shape by using the connector named "MASTER-ARM-PTR":

elements["MASTER-ARM-PTR"] = {

Then set its action as a toggle switcher both for the left and right mouse buttons (Class TUMB):

    class = {class_type.TUMB, class_type.TUMB},

(Other class types include BTN (button) for clickable buttons and LEV (level) for rotary switches which can set a level like a brightness or contrast control)

This sets the hint text when mouse pointer moves over it:

   hint = LOCALIZE("Master Arm"),  

(LOCALIZE is a service function which interacts with options "Cockpit Language")

This sets the parent device (target) for this element:

  device = devices.WEAP_INTERFACE,

When clicking on it send the command device_commands.Button_1 to the parent device, both by left and right mouse clicking:

  action = {device_commands.Button_1,device_commands.Button_1},

And do nothing when the mouse button is released:

  stop_action = {},

This changes the draw argument with a number (to visually move the switch):

  arg = {387,387},

by setting it to value = current_value + arg_value, (you can see that the right mouse button changes value in opposite direction):

  arg_value = {-1.0,1.0},

And set the argument limits (or bounds):

  arg_lim = {{0.0, 1.0},{0.0, 1.0}}, 

Use an object oriented bounding box to calculate position of element:

 use_OBB = true, 

And update its position after click:

 updatable = true

Element definition completed:

}
Personal tools