Problem Code works as an upper level function, but not when called.

dmurley

New member
Joined
Dec 11, 2017
Messages
37
Reaction score
0
Points
0
Location
Hill country (near San Antonio
I have a piece of code to establish a constant vertical velocity on the moon of 1 m/s which works just fine when invoked directly, but not when called. When called, the Delta Glider NT barely moves at all and settles back to the ground very quickly. I don't understand what is going on here. Any help would be appreciated.

Also, I am using 1.622 as the gravitational acceleration of the moon. I actually get better results using 1.624. What is the proper value to use?

Code:
-- VelOne
--
-- Description: The purpose of this function is to establish 
-- a constant vertical velocity of about 1 m/s on the moon.
--
-- Inputs:
--   dAcc - desired acceleration in g's
--
--   Assumptions:
--   1) A handle (hGLNT) to the interface of a vessel
--      is established before this routine is invoked.

function VelOne(dAcc)
 
  term.out ('Enter VelOne')
  pbA=1.622
  sA = (9.8*dAcc)-pbA		
  tA = 1/sA		
  curMass = hGLNT:get_mass()
  gF=curMass*pbA
  aF = curMass*sA
  tF=gF+aF
  eng0F=tF*.6026
  eng0L=eng0F/110000
  eng0HF=gF*.6026
  eng0HL=eng0HF/110000
  hGLNT:set_thrustergrouplevel(THGROUP.HOVER,eng0L)
  proc.wait_simdt(tA)
  hGLNT:set_thrustergrouplevel(THGROUP.HOVER,eng0HL)
  proc.wait_simdt(tA)
  term.out ('Exit VelOne')
end
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
9,385
Reaction score
117
Points
153
Location
between the planets
I'm not sure I follow... Invoking a function and calling it are the same thing. Maybe you could post the calling code as well?
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,491
Reaction score
19
Points
38
I'm not sure what you mean by "called" vs. "invoked"...

If it is something about "automatically run at scenario start" vs. "manually run later on", here's my guess:
It could be that the friction of the landing gear (wheels) make a difference, as they might not have gotten fully integrated into the (simulation-)state at scenario start.
When running the function manually (later that is) the friction might be fully integrated...


Note: this is only a guess, as I think I read something like this in another thread...
 

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
4,118
Reaction score
25
Points
73
Location
Dallas, TX
I think what he means is that the function works when run interactively by the user from the Lua console (I haven't run Orbiter in a while but I seem to recall there being a built-in MFD that functioned as a Lua console), but not when called programmatically.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
9,385
Reaction score
117
Points
153
Location
between the planets
In that case, logging the passed argument would be a good first thing to try.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
35,591
Reaction score
98
Points
138
Location
Langendernbach
Especially - I would log the type of the variable, since Lua is also dynamically typed.
 

dmurley

New member
Joined
Dec 11, 2017
Messages
37
Reaction score
0
Points
0
Location
Hill country (near San Antonio
I think what he means is that the function works when run interactively by the user from the Lua console (I haven't run Orbiter in a while but I seem to recall there being a built-in MFD that functioned as a Lua console), but not when called programmatically.
Yes. This is exactly what I meant (sorry if I wasn't clearer). Additional experimentation leads me to believe that all functions work ok (even when called progromatically) except for those where I set thruster values, wait a given period of time, then disable those thrusters. Can anybody verify that this is also happening to them?
 
Top