Jump to content

DCS-ExportScripts F-14B Tomcat .lua script w/Special Stream Deck exports


nosaMtrevoC

Recommended Posts

On 7/13/2021 at 9:33 AM, Simm0 said:

There's some pretty cool stuff in here and I have my F-14 almost working how I want in the stream deck thanks to everyone.

 

Just wondering if this work should be checked back into the main DCS Export Scripts git and we start managing it there?

Possible first step https://github.com/asherao/DCS-ExportScripts

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Yes, F-14A-135-GR.lua works just fine.

 

First of all, big thanks to @nosaMtrevoC for taking the time & pain to prepare the file! Very much appreciated!

 

Now, down to the business...
Have anybody cracked airspeed in Tomcat yet? Couldn't find it in F-14B.lua.

If not, I THINK I kind of did it, but not very "cheaply", so proceed at your own discretion.


I tried the least squares approximation, but didn't like the results (square and cubic polynomials, didn't look higher than that).
So I stayed with my crude polygonal chain approximation (I think that's how you call it in English, but I'm not sure).

 

I used var. number 2504, it seems to be free to take (I hope!).
Single KIAS (ones) are "trembling" a bit, so you may want to filter them out, or you can leave them, as you wish.

 

Seems to work fine, I've just done it and I'm still testing.
I you want, put the pieces of code at the 3 places (hints below). Ellipsis "(...)" means "some stuff of yours is probably here".

 

ExportScript.ConfigEveryFrameArguments =
{
-- (...)
		[2129] = "%.4f",  -- scoobie, what's this? KIAS needle maybe? YES! 
-- (...)
}


function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)

-- (...)

	local x = {0, 0.057, 0.1, 0.141, 0.212, 0.328, 0.427, 0.518, 0.588, 0.646, 0.731, 0.801, 0.867, 0.915, 1.000}
	local y = {0, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 1000} -- 1000 KIAS is fake just to fill the range
	ExportScript.Tools.SendData(2504, string.format("%d", ExportScript.Linearize(mainPanelDevice:get_argument_value(2129), x, y)))

-- (...)

-- somewhere at the bottom of the file:

function ExportScript.Linearize(current_value, raw_tab, final_tab)
  -- (c) scoobie
  if current_value <= raw_tab[1] then
    return final_tab[1] 
  end
  for index, value in pairs(raw_tab) do
    if current_value <= value then
      local ft = final_tab[index]
      local rt = raw_tab[index]
      return (current_value - rt) * (ft - final_tab[index - 1]) / (rt - raw_tab[index - 1]) + ft
    end
  end
  -- we shouldn't be here, so something went wrong - return arbitrary max. final value, maybe the user will notice the problem:
  return final_tab[#final_tab]
end

 

 


Edited by scoobie
  • Like 1

i7-8700K 32GB 2060(6GB) 27"@1080p TM Hawg HOTAS TPR TIR5 SD-XL button/pot box

Link to comment
Share on other sites

16 hours ago, scoobie said:

Yes, F-14A-135-GR.lua works just fine.

 

First of all, big thanks to @nosaMtrevoC for taking the time & pain to prepare the file! Very much appreciated!

 

Now, down to the business...
Have anybody cracked airspeed in Tomcat yet? Couldn't find it in F-14B.lua.

If not, I THINK I kind of did it, but not very "cheaply", so proceed at your own discretion.


I tried the least squares approximation, but didn't like the results (square and cubic polynomials, didn't look higher than that).
So I stayed with my crude polygonal chain approximation (I think that's how you call it in English, but I'm not sure).

 

I used var. number 2504, it seems to be free to take (I hope!).
Single KIAS (ones) are "trembling" a bit, so you may want to filter them out, or you can leave them, as you wish.

 

Seems to work fine, I've just done it and I'm still testing.
I you want, put the pieces of code at the 3 places (hints below). Ellipsis "(...)" means "some stuff of yours is probably here".

 

ExportScript.ConfigEveryFrameArguments =
{
-- (...)
		[2129] = "%.4f",  -- scoobie, what's this? KIAS needle maybe? YES! 
-- (...)
}


function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)

-- (...)

	local x = {0, 0.057, 0.1, 0.141, 0.212, 0.328, 0.427, 0.518, 0.588, 0.646, 0.731, 0.801, 0.867, 0.915, 1.000}
	local y = {0, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 1000} -- 1000 KIAS is fake just to fill the range
	ExportScript.Tools.SendData(2504, string.format("%d", ExportScript.Linearize(mainPanelDevice:get_argument_value(2129), x, y)))

-- (...)

-- somewhere at the bottom of the file:

function ExportScript.Linearize(current_value, raw_tab, final_tab)
  -- (c) scoobie
  if current_value <= raw_tab[1] then
    return final_tab[1] 
  end
  for index, value in pairs(raw_tab) do
    if current_value <= value then
      local ft = final_tab[index]
      local rt = raw_tab[index]
      return (current_value - rt) * (ft - final_tab[index - 1]) / (rt - raw_tab[index - 1]) + ft
    end
  end
  -- we shouldn't be here, so something went wrong - return arbitrary max. final value, maybe the user will notice the problem:
  return final_tab[#final_tab]
end
 

 

 

 

Nice. Can this be adapted to other aircraft with similar airspeed dials by changing the local x and y values?

Link to comment
Share on other sites

Yes, you can! 🙂

Airspeed or whatever that seems to have non-linear scale (e.g. VVIs are often non-linear).

 

It's just... it's best to put as few numbers into these tables as is sufficient for acceptable errors. Otherwise, if the current value of the variable (instrument needle position etc.) is high (close to 1.000 according to DCS "ideology"), Lua will have to - upon rendering every damned frame - run through a lot of elements in the x table to finally find the "subrange" we are in. It's needlessly slow.

 

In the code above I put ALL the points on airspeed indicator's scale I had "measured" with Model Viewer. It's bad, but it's because F-14B.lua is "early WIP" for me, I just bought the Cat. I suspect there maybe fewer of these points.

 

Oh, and of course - in simple cases a simpler solution is favourable: nothing beats the simplest "y = ax + b" or "if (x > something) then y = a1x + b1 else y = a2b + b2 end". AFAICR you put quite a few of such statements in Mi-24. They are faster to run.

 

  • Thanks 1

i7-8700K 32GB 2060(6GB) 27"@1080p TM Hawg HOTAS TPR TIR5 SD-XL button/pot box

Link to comment
Share on other sites

20 hours ago, scoobie said:

Yes, F-14A-135-GR.lua works just fine.

 

First of all, big thanks to @nosaMtrevoC for taking the time & pain to prepare the file! Very much appreciated!

 

Now, down to the business...
Have anybody cracked airspeed in Tomcat yet? Couldn't find it in F-14B.lua.

If not, I THINK I kind of did it, but not very "cheaply", so proceed at your own discretion.


I tried the least squares approximation, but didn't like the results (square and cubic polynomials, didn't look higher than that).
So I stayed with my crude polygonal chain approximation (I think that's how you call it in English, but I'm not sure).

 

I used var. number 2504, it seems to be free to take (I hope!).
Single KIAS (ones) are "trembling" a bit, so you may want to filter them out, or you can leave them, as you wish.

 

Seems to work fine, I've just done it and I'm still testing.
I you want, put the pieces of code at the 3 places (hints below). Ellipsis "(...)" means "some stuff of yours is probably here".

 

ExportScript.ConfigEveryFrameArguments =
{
-- (...)
		[2129] = "%.4f",  -- scoobie, what's this? KIAS needle maybe? YES! 
-- (...)
}


function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)

-- (...)

	local x = {0, 0.057, 0.1, 0.141, 0.212, 0.328, 0.427, 0.518, 0.588, 0.646, 0.731, 0.801, 0.867, 0.915, 1.000}
	local y = {0, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 1000} -- 1000 KIAS is fake just to fill the range
	ExportScript.Tools.SendData(2504, string.format("%d", ExportScript.Linearize(mainPanelDevice:get_argument_value(2129), x, y)))

-- (...)

-- somewhere at the bottom of the file:

function ExportScript.Linearize(current_value, raw_tab, final_tab)
  -- (c) scoobie
  if current_value <= raw_tab[1] then
    return final_tab[1] 
  end
  for index, value in pairs(raw_tab) do
    if current_value <= value then
      local ft = final_tab[index]
      local rt = raw_tab[index]
      return (current_value - rt) * (ft - final_tab[index - 1]) / (rt - raw_tab[index - 1]) + ft
    end
  end
  -- we shouldn't be here, so something went wrong - return arbitrary max. final value, maybe the user will notice the problem:
  return final_tab[#final_tab]
end

 

 

 

I had tried cracking this nut but the solution I had was causing the sim to lock up after a while. I think I had a bad if loop in it somewhere.

Link to comment
Share on other sites

  • 2 weeks later...
On 9/15/2021 at 8:59 AM, hasole said:

Does anyone have the chaff/flare counters working on their stream deck? 

Are you looking for a solution, fix, or a new implementation? I think I see the counters in the jet as IDs 392-395. I have tried, but about 1 out of every 10 or so smooth rotations does not update the output for some reason. I have noticed quite a lot of "jitter" on the animation output. Maybe it wont update due to too many jitter calculations?


Edited by Bailey
Link to comment
Share on other sites

1 hour ago, Bailey said:

Are you looking for a solution, fix, or a new implementation? I think I see the counters in the jet as IDs 392-395.

 

On 9/13/2021 at 2:29 PM, scoobie said:

Yes, you can! 🙂

Airspeed or whatever that seems to have non-linear scale (e.g. VVIs are often non-linear).

 

It's just... it's best to put as few numbers into these tables as is sufficient for acceptable errors. Otherwise, if the current value of the variable (instrument needle position etc.) is high (close to 1.000 according to DCS "ideology"), Lua will have to - upon rendering every damned frame - run through a lot of elements in the x table to finally find the "subrange" we are in. It's needlessly slow.

 

In the code above I put ALL the points on airspeed indicator's scale I had "measured" with Model Viewer. It's bad, but it's because F-14B.lua is "early WIP" for me, I just bought the Cat. I suspect there maybe fewer of these points.

 

Oh, and of course - in simple cases a simpler solution is favourable: nothing beats the simplest "y = ax + b" or "if (x > something) then y = a1x + b1 else y = a2b + b2 end". AFAICR you put quite a few of such statements in Mi-24. They are faster to run.

 

I'll admit, it has taken me 3 months to finally understand what in the world you did in that lua formula! I started doing the spitfire in preparation for the mossie (waiting for free trial period to start, eventually). I did the values via my old way of equations, with one having a 5th order polynomial. 😄 Whatever gets the job done I guess. After failing to get a good solution for the chaff/flare readouts I tried your method of linear interpolation within the table and it has been working fine for me for the F14B airspeed readout. Pretty spot on, no complaints. When I finally get my hands on the mossie  I'll be glad to be skipping the step of using excel and copy-pasting the formula that pops out. Sure, your function may be slower, but the update rate is still fast enough to feel fine. That, plus rounding off the final digit for stuff like altimeter readings and no-one will know the difference!

Link to comment
Share on other sites

Ha, it's a bit of a pity as I actually preferred your solution over mine... even more so if someone else came up with a ready to use formula 😉
Laziness is a bad thing, I know, I know.
I have no idea about this whole Lua language-like thing, so I wonder if 5th order polynomial isn't even slower than searching through a table, who knows.

 

I'm very glad if you can make any use of this junk of mine in any of the cool things you're doing for folks here. That's the least I could do, really.

 

i7-8700K 32GB 2060(6GB) 27"@1080p TM Hawg HOTAS TPR TIR5 SD-XL button/pot box

Link to comment
Share on other sites

On 7/13/2021 at 9:33 AM, Simm0 said:

There's some pretty cool stuff in here and I have my F-14 almost working how I want in the stream deck thanks to everyone.

 

Just wondering if this work should be checked back into the main DCS Export Scripts git and we start managing it there?

I took the dive and decided to open my Git as a public library. Feel free to add to it.


Edited by Bailey
Link to comment
Share on other sites

On 9/29/2021 at 2:15 AM, scoobie said:

Ha, it's a bit of a pity as I actually preferred your solution over mine... even more so if someone else came up with a ready to use formula 😉
Laziness is a bad thing, I know, I know.
I have no idea about this whole Lua language-like thing, so I wonder if 5th order polynomial isn't even slower than searching through a table, who knows.

 

I'm very glad if you can make any use of this junk of mine in any of the cool things you're doing for folks here. That's the least I could do, really.

 

The results are in. The exponential equation is about 6 times "faster" compared to the process of a linearly interpolated table. Each operation was done 10 million times.
 unknown.png
Maybe exponential may be the way to go if you have like 20 of these on the SD at once or if an animation has a particularly nasty equation. 


Edited by Bailey
Link to comment
Share on other sites

How interesting! Those orbit-high-level languages, you never know what's going on under the hood.
Or at least I have no idea what's going on, it's never been my cup of tea or a job, I'm kind of scared of such "abstract" languages 😄

 

---------

 

A little off-topic if I may...

Great idea with the github lib! I... don't quite feel like... "in position" to impose my sick ideas on other people, in these export scripts, so I guess I won't contribute there (moreover, I never did anything on Github, don't know how this thing works, I only know standalone Git), but is there a place on the forums here where one could present their sick ideas - more as "desing ideas" than ready to use solutions? A fishing rod, not the fish.


It just occurred to me that I have one more odd patent up the sleeve and I'm not sure if anyone came up with it before (maybe, maybe not - these forums are really huge).
But I don't want to mess up this thread, it's messed up enough already 🙂

 

PS. The idea I'm talking about came to me with the Dora. I have all the gear up/down and flaps down/mid/up annunciator lights (so... 7 lamps) on a single SD button. Doesn't look great, isn't terribly practical (in a Dora at least), but does the job - I'm often absent-minded and this allows me to quickly glimpse and check if she's really set up for landing.
 

PS. Oh, and one more, but maybe it's known already? My ugly "which fuel tank is on + tell me gallons of fuel in them" for the P-51. It looks... ugly (all things I do look ugly, unfortunately).

 

Pictures:
Dora with gear down and flaps in "start" position, next picture is gear down and flaps up.
And last one is the Pony with 89 gallons (IIRC it's "floored" value, not rounded) in each wing tank, 0 gallons in the center tank and left wing tank is currently selected (square brackets around the number). "LD" and "RD" stand for "left drop" and "right drop", Pony doesn't know how much fuel is there, so no fuel contents is given for them.

 

gear_dn_flaps_mid.PNG

gear_dn_flaps_up.PNG

pony_fuel.PNG


Edited by scoobie

i7-8700K 32GB 2060(6GB) 27"@1080p TM Hawg HOTAS TPR TIR5 SD-XL button/pot box

Link to comment
Share on other sites

2 hours ago, scoobie said:

How interesting! Those orbit-high-level languages, you never know what's going on under the hood.
Or at least I have no idea what's going on, it's never been my cup of tea or a job, I'm kind of scared of such "abstract" languages 😄

 

---------

 

A little off-topic if I may...

Great idea with the github lib! I... don't quite feel like... "in position" to impose my sick ideas on other people, in these export scripts, so I guess I won't contribute there (moreover, I never did anything on Github, don't know how this thing works, I only know standalone Git), but is there a place on the forums here where one could present their sick ideas - more as "desing ideas" than ready to use solutions? A fishing rod, not the fish.


It just occurred to me that I have one more odd patent up the sleeve and I'm not sure if anyone came up with it before (maybe, maybe not - these forums are really huge).
But I don't want to mess up this thread, it's messed up enough already 🙂

 

PS. The idea I'm talking about came to me with the Dora. I have all the gear up/down and flaps down/mid/up annunciator lights (so... 7 lamps) on a single SD button. Doesn't look great, isn't terribly practical (in a Dora at least), but does the job - I'm often absent-minded and this allows me to quickly glimpse and check if she's really set up for landing.
 

PS. Oh, and one more, but maybe it's known already? My ugly "which fuel tank is on + tell me gallons of fuel in them" for the P-51. It looks... ugly (all things I do look ugly, unfortunately).

 

Pictures:
Dora with gear down and flaps in "start" position, next picture is gear down and flaps up.
And last one is the Pony with 89 gallons (IIRC it's "floored" value, not rounded) in each wing tank, 0 gallons in the center tank and left wing tank is currently selected (square brackets around the number). "LD" and "RD" stand for "left drop" and "right drop", Pony doesn't know how much fuel is there, so no fuel contents is given for them.

 

gear_dn_flaps_mid.PNG

gear_dn_flaps_up.PNG

pony_fuel.PNG

 

The great part about a library is that not only are there already books there, but ppl go there to study, learn, and discuss too! It’s a very flexible place. Yes, the ExportScripts Library is the perfect place to post these ideas of yours. I, too, am quite curious… 

 

Don't worry about the GitHub part. I’ll take care of that. 


Edited by Bailey
Link to comment
Share on other sites

On 9/28/2021 at 11:33 PM, Bailey said:

Are you looking for a solution, fix, or a new implementation? I think I see the counters in the jet as IDs 392-395. I have tried, but about 1 out of every 10 or so smooth rotations does not update the output for some reason. I have noticed quite a lot of "jitter" on the animation output. Maybe it wont update due to too many jitter calculations?

 

Hi @Bailey

I'm just after a counter as I'm always the pilot.

Link to comment
Share on other sites

1 hour ago, hasole said:

Another question, in the controls there are options to bind some jester commands.  Would they be possible to pull via this instead of using hotkeys on the stream deck?

Yes

Link to comment
Share on other sites

Another question, in the controls there are options to bind some jester commands.  Would they be possible to pull via this instead of using hotkeys on the stream deck?
I'd suggest using voice attack for jester commands. Works great!

Sent from my SM-G781U using Tapatalk

Link to comment
Share on other sites

  • Recently Browsing   0 members

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