Jump to content

get_clickable_element_reference in aircraft cockpit lua code


gyrovague

Recommended Posts

Posting this to people of the future because google currently has zero results for "get_clickable_element_reference", and I figured out how to use it. Hopefully soon this post will become the only google hit for this.

 

You can call get_clickable_element_reference("POINT_NAME"), where "POINT_NAME" comes from one of your items in your clickabledata.lua (index of the elements).

 

On the result of that, you can then call the following functions:

set_hint
update
hide

 

set_hint updates the mouseover text of the clickable element dynamically (pass a string as an argument), hide takes a boolean as argument and changes whether the element is clickable or not (useful if you want elements to not be clickable under certain logic conditions), and update (takes no arguments) is useful to get a clickable element to update its connector position (this is useful if you have changed the cockpit draw argument of a clickable item (e.g. via a parameter gauge) instead of using the clickable animations (which are sometimes problematic since they only emit the command after the animation has completed, and you might want to employ some logic as soon as it is clicked before it starts animating) ).

 

Example (emulating a gear lever which is locked by solenoid when on the ground, so make it non-clickable):

    if prev_retraction_release_airborne ~= retraction_release_airborne then
       local gear_clickable_ref = get_clickable_element_reference("PNT_8") -- gear lever
       prev_retraction_release_airborne = retraction_release_airborne
       gear_clickable_ref:hide(not retraction_release_airborne)  -- make non-clickable if not airborne, and clickable when airborne
   end

____________

Heatblur Simulations

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

how did you find out how to use this, or find it in the first place. I am too trying to find out how the functions of the cockpit but its harder than splitting an atom :) (or i am just to stupid)

'controlling' the Ka50 feels like a discussion with the Autopilot and trim system about the flight direction.

Link to comment
Share on other sites

how did you find out how to use this, or find it in the first place. I am too trying to find out how the functions of the cockpit but its harder than splitting an atom :) (or i am just to stupid)

 

A combination of recursively dumping metatable from _G to discover available function names, and trial&error&guesswork for the function parameters. In this particular case, I discovered the get_clickable_element_reference function directly in the _G metatable, then had to guess its param, which I finally got as the point name which the element was defined with, then I had to dump the metatable of the result of that to see that it had the set_hint, update and hide functions, and then had to guess their parameters. So it goes with DCS modding when you have no access to documentation, and when google doesn't give you a link to a forum post with the answer on it.

____________

Heatblur Simulations

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

 

I have used this tool (thanks uboats!) a lot too, and it is useful, but it is orthogonal to what I wrote above. When you have your own cockpit and plane EDM, you don't need this tool as much anymore, since you can then keep internal documentation of what each arg is for (and the ranges etc.). It is very handy for poking at other EDM files though to get an idea of how they do things.

____________

Heatblur Simulations

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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