Jump to content

Lua, DCS-bios and values


outbaxx

Recommended Posts

Hi guys

 

I’m having some issues reading and comparing values in my .lua.

I’m exporting values for a display and with number 0-9 it’s no problem, those values are sent as 0.1 to 0.9 and I sub(3) them so I send 0-9 to my arduino.

I had a issue with “ “ (blank) as that value was send as -1.6 but I solved it by:

(Code not exakt as I’m writing on my phone)

 

If device(0):argnr(567) < 0.0 then

“data1” = “ “

 

This does not work:

 

If device(0):argnr(567) == -1.6 then

“data1” = “ “

 

But now I want to display a “-“ and that value is sent as -0.3.

But I can’t compare that like:

 

If device(0):argnr(567) == -0.3 then

“data1” = “-“

 

The control reference still show -0.3 and so is the display. So the value it should compare seem to differ from what I get in the control reference or am I doing something else wrong?

 

Regards

F

Link to comment
Share on other sites

The drawargs are represented in C++ in DCS as floats. Because how they work they might not always do exactly how you think they would. You can google this more precisely but anyway my bet is that -0.3 isn't really -0.3 but instead something like -0.29999999998 or -0.3000000001. You can fix this by adding an acceptable range to identify the value you are looking for, something like this:

 

if device(0):argnr(567) <= -0.31 and device(0):argnr(567) >= -0.29 then

"data1" = "-"

 

or you can ofcourse find the exact represented value and look for that.

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Lua, DCS-bios and values

 

The drawargs are represented in C++ in DCS as floats. Because how they work they might not always do exactly how you think they would. You can google this more precisely but anyway my bet is that -0.3 isn't really -0.3 but instead something like -0.29999999998 or -0.3000000001. You can fix this by adding an acceptable range to identify the value you are looking for, something like this:

 

if device(0):argnr(567) = -0.29 then

"data1" = "-"

 

or you can ofcourse find the exact represented value and look for that.

 

 

 

Haha, I just solved it by doing exactly this :) I used <-0.4 and >0.0 as I didn’t think about floats. My output was %.1f so that’s why I thought it was a “even” number.

Thanks!!


Edited by outbaxx
Link to comment
Share on other sites

  • Recently Browsing   0 members

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