Page 1 of 1

Setting altitude

Posted: Fri Mar 13, 2020 1:20 pm
by Gunner98
Using the command:

ScenEdit_SetUnit({side="NATO", unitname="101 Sqn RAF #1", altitude=10972.6, speed=230})

works fine, but note that the command uses meters and you must have the decimal point included. 10972.6 (or 7 or 8 or 9) returns 36,000.7 ft ASL which is fine but -

Is there a way to simply give the command in feet and avoid the '.7'

BTW, the documentation notes the meters but doesn't mention using the decimal point.

Thanks

RE: Setting altitude

Posted: Fri Mar 13, 2020 2:54 pm
by TitaniumTrout
So if you give it the command without a decimal value then it just sets it to zero, correct? That's what I see in my testing.

Code: Select all

local a = ScenEdit_SetUnit({side="BLUFOR", unitname="Airplane", altitude = 7000, manualaltitude=7010, manualspeed=410})
 print(a)
 

Image

A few things you can do. One, just add a decimal after the value. Setting the "altitude = 7000." is enough to make it work. Odd that it doesn't also happen with speed, probably something going on with a conversion.

You could also include a conversion so you don't have to think in meters. then you'd do "altitude = (3600/3.281)".

Interestingly enough that works, however I'm running into some oddities setting the math on the manualaltitude side of things. I can divide 3000/3 and it sets it to 3,281 ft. However if I try to divide 3000/3.281 it sets it to 20 ft. Dividing 4000/3 also sets it to 20 ft.

Code: Select all

local man = 1000/3
 print(man)
 
 local a = ScenEdit_SetUnit({side="BLUFOR", unitname="Airplane", altitude = (3000/3.281), manualaltitude=man, manualspeed=400})
 print(a)

Manual override goes to 20 ft.

Code: Select all

local man = 333
 print(man)
 
 local a = ScenEdit_SetUnit({side="BLUFOR", unitname="Airplane", altitude = (3000/3.281), manualaltitude=man, manualspeed=400})
 print(a)

Manual altitude goes to 1093 ft.

333.0 returns 1093 ft.
333.3 returns 20 ft.

I'll cross post this as a bug? Unless I'm missing something.






RE: Setting altitude

Posted: Fri Mar 13, 2020 4:15 pm
by Gunner98
So if you give it the command without a decimal value then it just sets it to zero, correct? That's what I see in my testing

Yes that is exactly what is happening to me. I do believe there is something to do with rounding as the same result (36000.7 ft ASL) in feet appears with multiple altitude entries (altitude=10972.6 or .7, or .8 or .9)


This is very workable but I do think something may be off.

Thanks for checking into it.

B

RE: Setting altitude

Posted: Fri Mar 13, 2020 11:27 pm
by michaelm75au
This may be a side affect of moving to Lua 5.3 as in Lua 5.2 all numbers were treated as decimal/floats that is not the case in L5.3. The suggestion from the L5.3 manual is to force it to a float by adding a decimal point to it. . As TT suggests.

I need to check how the values are being passed to the SE_SetUnit() as funny speed works and altitude doesn't - we came across something like this on a different function when testing the changes.

Verified and fixed for a future build.

RE: Setting altitude

Posted: Fri Mar 13, 2020 11:30 pm
by michaelm75au
BTW you should be able to put the value in feet.

{altitude='100 FT'}

RE: Setting altitude

Posted: Sat Mar 14, 2020 9:34 am
by Gunner98
Cheers, thanks Michael

B