Thanks for this, very handy ! Indeed Altitude parameter would be useful too ...Ralph wrote: ↑Thu Dec 15, 2022 6:54 pm Isn't that the same as this function?
https://siminnovations.com/wiki/index.p ... c_distance
Great Circle Distance calculator example (with altitude compensation) Lua
-
- Posts: 5346
- Joined: Thu Jul 27, 2017 12:22 am
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Thank you and you are very welcome GIlles. I think as it currently the most elegant solution with altitude that can also be varied. Everything can be improved of courseSimPassion wrote: ↑Fri Dec 16, 2022 11:27 amThanks for this, very handy ! Indeed Altitude parameter would be useful too ...Ralph wrote: ↑Thu Dec 15, 2022 6:54 pm Isn't that the same as this function?
https://siminnovations.com/wiki/index.p ... c_distance
Joe
Joe. CISSP, MSc.
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Yes sir, it is specific, Previously I never found the LUA 'block' comment.. it was a revelation to say the least.SimPassion wrote: ↑Fri Dec 16, 2022 11:25 amGreat find, just noticed the ending tag "--]]" which is not obvious, though indeed logical, having "--" at first then "]]", as we used to rather inverted ones on the usual for example with c++ which is "/*" followed by "*/" and similar in multiple coding languages ...jph wrote: ↑Fri Dec 16, 2022 9:42 am Thanks Ralph,
Altitude addition makes a heck of a lot of difference in calcs.
I can easily add the RHUMB option and also the various feet / meters / km / miles options etc if needed as the basic code is sorted.
Without altitude (which we never needed in sailing lol ) it is not as accurate for flight calculation.
One thing I found really useful during this experiment was the use of --[[ and --]] for lua code block comment. I had never previously seen that but searched for answers and eventually came across the --[[ and --]]
Rather nice.
You may well know this but I have not seen it in examples that I have looked at -try the following copy and past into AM
Code: Select all
-- this is a normal simple LUA comment this is not a comment but will cause errors --[[ this is a BLOCK comment in LUA. All comments are included in between the markers So this is still included. And this. And even this. this is how we end the block comment --]] x = 5 -- this is code followed by a comment -- notice the difference ? --[[ the difference is subtle but extremely useful Joe Hanley - 2022 I am sure it is pointed out on the wiki but i have missed it. Now I have found it I love it haha (as the actress said to the bishop) --]]
It is so strange that we often miss things that are in front of us.
I love lua, it never ceases to amaze me with its total elegance and its total F&CK ups at the same time .. It really is very very nice though.
Joe
Joe. CISSP, MSc.
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Honestly, I wonder how many have found the lua block comment ?
I had never seen it used in ANY previous example with AM
It can definitely be used more in descriptions and details
Joe
Code: Select all
--[[
text1
text2
text3
text4
--]]
It can definitely be used more in descriptions and details
Joe
Joe. CISSP, MSc.
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Hijph wrote: ↑Fri Dec 16, 2022 12:20 pm Honestly, I wonder how many have found the lua block comment ?
I had never seen it used in ANY previous example with AMCode: Select all
--[[ text1 text2 text3 text4 --]]
It can definitely be used more in descriptions and details
Joe
I have used it often for years.
Did you find it in the commented out text in the clone instrument I posted in the AM4.2 bug thread??
Code: Select all
function CloseGuard(switch, yes)
local s = gSwitch[switch]
visible(s.img_closed, yes)
visible(s.img_open, not yes)
s.closed = yes
end
-- ====================== operate switches ==================
--[[
---------------------- Gen1 switch ----------------
local gSwitchGen1
function cbSwitchGen1(switch, dir)
if dir > 0 then
fs2020_event("ROTOR_BRAKE", 2701)
else
fs2020_event("ROTOR_BRAKE", 2702)
end
end
fs2020_variable_subscribe("L:switch_27_73X", "number", function(v)
SetSwitchPosition(gSwitchGen1, math.floor(v/50)+1)
end)
gSwitchGen1 = AddVerticalSwitch(105, 301, true, true, true, cbSwitchGen1)
]]
Code: Select all
--[[
bla
blaa
]]
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Great Circle Distance calculator example (with altitude compensation) Lua
Hi Keith
Sorry but I didnt download the SIFF file. For small pieces of code, such as this, I much prefer the function itself to be embedded where possible so it can be copied and pasted.
But great to hear that you found it too. It had to be there somewhere as every other language I use or have used has a similar option available.
Thanks for the info.
Joe
Sorry but I didnt download the SIFF file. For small pieces of code, such as this, I much prefer the function itself to be embedded where possible so it can be copied and pasted.
But great to hear that you found it too. It had to be there somewhere as every other language I use or have used has a similar option available.
Thanks for the info.
Joe
Joe. CISSP, MSc.