Setting altitude

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Setting altitude

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Setting altitude

Post 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.





User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Setting altitude

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Setting altitude

Post 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.
Michael
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Setting altitude

Post by michaelm75au »

BTW you should be able to put the value in feet.

{altitude='100 FT'}
Michael
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Setting altitude

Post by Gunner98 »

Cheers, thanks Michael

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Post Reply

Return to “Lua Legion”