s-d-a / DCS-ExportScripts

DCS World Export Scripts
GNU Lesser General Public License v3.0
114 stars 52 forks source link

HELP: Custom functions and math #13

Open theonegalen opened 3 years ago

theonegalen commented 3 years ago

I'm currently building a StreamdeckXL profile for the F-5E. While trying to set up a streamdeck display for the chaff and flare counts, the tens and ones positions are associated with different DCS IDs. This means I have to use two different buttons for the chaff and flare displays, like this:

https://i.imgur.com/YkFJUSY.png

If I could do something to add those two together, like

[new function number] = ([401]*100)+([402]*10)

Then I could just have my streamdeck display the result. But I have no idea how to do this. I see that at the bottom of the F-5E-3.lua file included with DCS-ExportScripts, there's a section called "custom functions." Is there any way to program that new function in the lua file?

shugamoe commented 2 years ago

Try something like:

local new_number = mainPanelDevice:get_argument_value(401) * 100 + mainPanelDevice:get_argument_value(402) * 10

For an example of a custom function, see line 524 of this.