Orbiter BETA Lua development

xjflcf520

Member
Joined
Feb 26, 2021
Messages
57
Reaction score
5
Points
8
Location
Chana
Hello again,

I've managed to port the old project/solution to Visual Studio 2017 and was able to dig into the touchdownpoints issue.
There was actually a bug in the interface implementation 😊
So, in the 1st post you'll find a new ZIP (LuaScript 2021-03-30(dlls).zip) for Orbiter BETA which you can try!
I will provide the Builds (ZIPs) for Orbiter 2016 when I find the time to do it.

Attached, my test Lua (overwrite Orbiters Script\Tests\unit_test.lua file and run it via Scenarios\Tests\unit_test.scn).
I had to rename it to unit_test.lua.txt as .lua is a not accepted attachment extenssion, but I guess you know how to rename it ;)

The "relevant" parts here:
Code:
add_line("Test: vessel:get_touchdownpoints()")
v = vessel.get_interface("GL-01")
td1,td2,td3 = v:get_touchdownpoints()
assert(td1.x == 0 and td1.y == -1.5 and td1.z == 9 and td2.x == -6 and td2.y == -0.8 and td2.z == -5 and td3.x == 3 and td3.y == -1.2 and td3.z == -5)
v:Gear(1)
proc.wait_simdt(7)
td1,td2,td3 = v:get_touchdownpoints()
assert(td1.x == 0 and td1.y == -2.57 and td1.z == 10 and td2.x == -3.5 and td2.y == -2.57 and td2.z == -1 and td3.x == 3.5 and td3.y == -2.57 and td3.z == -1)
v:Gear(0)
proc.wait_simdt(7)
td1,td2,td3 = v:get_touchdownpoints()
assert(td1.x == 0 and td1.y == -1.5 and td1.z == 9 and td2.x == -6 and td2.y == -0.8 and td2.z == -5 and td3.x == 3 and td3.y == -1.2 and td3.z == -5)
pass()

add_line("Test: vessel:get_touchdownpointcount()")
v = vessel.get_interface("GL-01")
tdc = v:get_touchdownpointcount()
assert(tdc == 13)
pass()

exp = {} -- expected "gear up" results
exp[ 0] = {pos={x=0, y=-1.5, z=9}, stiffness=1e7, damping=1e5, mu=3.5445e-08, mu_lng=3}
exp[ 1] = {pos={x=-6, y=-0.8, z=-5}, stiffness=1e7, damping=1e5, mu=2.21197e-08, mu_lng=3}
exp[ 2] = {pos={x=3, y=-1.2, z=-5}, stiffness=1e7, damping=1e5, mu=4.24352e-08, mu_lng=3}
exp[ 3] = {pos={x=-8.5, y=-0.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=-9.12894e+306, mu_lng=3}
exp[ 4] = {pos={x=8.5, y=-0.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=-1.63524e-206, mu_lng=3}
exp[ 5] = {pos={x=-8.5, y=-0.4, z=-3}, stiffness=1e7, damping=1e5, mu=2.00016, mu_lng=3}
exp[ 6] = {pos={x=8.5, y=-0.4, z=-3}, stiffness=1e7, damping=1e5, mu=1.03171e+26, mu_lng=3}
exp[ 7] = {pos={x=-8.85, y=2.3, z=-5.05}, stiffness=1e7, damping=1e5, mu=1.42505e+103, mu_lng=3}
exp[ 8] = {pos={x=8.85, y=2.3, z=-5.05}, stiffness=1e7, damping=1e5, mu=9.53414e-130, mu_lng=3}
exp[ 9] = {pos={x=-8.85, y=2.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=5.50352e-53, mu_lng=3}
exp[10] = {pos={x=8.85, y=2.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=5.88118e-308, mu_lng=3}
exp[11] = {pos={x=0,y=2, z=6.2}, stiffness=1e7, damping=1e5, mu=2.93186e-308, mu_lng=3}
exp[12] = {pos={x=0,y=-0.6, z=10.65}, stiffness=1e7, damping=1e5, mu=1.42005e-306, mu_lng=3}

exp2 = {} -- expected "gear down" results
exp2[0] = {pos={x=0, y=-2.57, z=10}, stiffness=1e6, damping=1e5, mu=9.09091e-08, mu_lng=1.6}
exp2[1] = {pos={x=-3.5, y=-2.57, z=-1}, stiffness=1e6, damping=1e5, mu=4.54545e-07, mu_lng=3}
exp2[2] = {pos={x=3.5, y=-2.57, z=-1}, stiffness=1e6, damping=1e5, mu=4.54545e-07, mu_lng=3}
exp2[3] = {pos={x=-8.5, y=-0.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=-5.10637e-310, mu_lng=3}
exp2[4] = {pos={x=8.5, y=-0.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=3.11088e-302, mu_lng=3}
exp2[5] = {pos={x=-8.5, y=-0.4, z=-3}, stiffness=1e7, damping=1e5, mu=0, mu_lng=3}
exp2[6] = {pos={x=8.5, y=-0.4, z=-3}, stiffness=1e7, damping=1e5, mu=0, mu_lng=3}
exp2[7] = {pos={x=-8.85, y=2.3, z=-5.05}, stiffness=1e7, damping=1e5, mu=0, mu_lng=3}
exp2[8] = {pos={x=8.85, y=2.3, z=-5.05}, stiffness=1e7, damping=1e5, mu=0, mu_lng=3}
exp2[9] = {pos={x=-8.85, y=2.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=nil, mu_lng=3}
exp2[10] = {pos={x=8.85, y=2.3, z=-7.05}, stiffness=1e7, damping=1e5, mu=-3.53744e-310, mu_lng=3}
exp2[11] = {pos={x=0, y=2, z=6.2}, stiffness=1e7, damping=1e5, mu=2.76101e-309, mu_lng=3}
exp2[12] = {pos={x=0, y=-0.6, z=10.65}, stiffness=1e7, damping=1e5, mu=0, mu_lng=3}

add_line("Test: vessel:get_touchdownpoints(GEARUP \"NewAPI\")")
v = vessel.get_interface("GL-01")
tdc = v:get_touchdownpointcount()
for i=0,tdc-1 do
  tdp = v:get_touchdownpoints(i)
  assert(tdp.pos.x == exp[i].pos.x and tdp.pos.y == exp[i].pos.y and tdp.pos.z == exp[i].pos.z
     and tdp.stiffness == exp[i].stiffness
     and tdp.damping == exp[i].damping
   --and  tdp.mu == exp[i].mu
     and tdp.mu_lng == exp[i].mu_lng
  )
end
pass()
v:Gear(1)
proc.wait_simdt(7)
add_line("Test: vessel:get_touchdownpoints(GEARDOWN \"NewAPI\")")
for i=0,tdc-1 do
  tdp = v:get_touchdownpoints(i)
  assert(tdp.pos.x == exp2[i].pos.x and tdp.pos.y == exp2[i].pos.y and tdp.pos.z == exp2[i].pos.z
     and tdp.stiffness == exp2[i].stiffness
     and tdp.damping == exp2[i].damping
   --and  tdp.mu == exp2[i].mu
     and tdp.mu_lng == exp2[i].mu_lng
  )
end
pass()
v:Gear(0)
proc.wait_simdt(7)
add_line("Test: vessel:get_touchdownpoints(GEARUP2 \"NewAPI\")")
for i=0,tdc-1 do
  tdp = v:get_touchdownpoints(i)
  assert(tdp.pos.x == exp[i].pos.x and tdp.pos.y == exp[i].pos.y and tdp.pos.z == exp[i].pos.z
     and tdp.stiffness == exp[i].stiffness
     and tdp.damping == exp[i].damping
   --and  tdp.mu == exp[i].mu
     and tdp.mu_lng == exp[i].mu_lng
  )
end
pass()

add_line("Test: vessel:set_touchdownpoints(\"NewAPI\")")
v = vessel.get_interface("GL-01")
arr = {}
arr[1] = v:get_touchdownpoints(0) -- NEW, 'cause index provided
arr[2] = v:get_touchdownpoints(1) -- NEW,   "     "     "
arr[3] = v:get_touchdownpoints(2) -- NEW,   "     "     "
arr[4] = v:get_touchdownpoints(3) -- NEW,   "     "     "
arr[5] = v:get_touchdownpoints(4) -- NEW,   "     "     "
arr[6] = v:get_touchdownpoints(5) -- NEW,   "     "     "
v:set_touchdownpoints(arr)
pass()

--note:set_colour ({r=0,g=0.9,b=0})
add_line("=== All tests passed ===", "green")
Hello, I tried to use part of the code about setting touchdownpoints in your Lua file, and verified whether it was set successfully, but the test failed. Is it because my spaceship was created through spacecraft 3 instead of being created as a DLL model that my spaceship could not set touchdownpoints
 

N_Molson

Addon Developer
Addon Developer
Donator
Addon List Curator
Joined
Mar 5, 2010
Messages
7,547
Reaction score
689
Points
188
Location
Toulouse
AFAIK you don't even need a module if you go "full LUA" ; I think to remember that Martins provided a full LUA implementation of the ShuttlePB at some point (correct me if I'm wrong).

Edit : yes just checked out search for "ScriptPB.cfg" in Orbiter 2016 beta configuration files.
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,653
Reaction score
170
Points
63
Wow, didn't know that[1] existed - thanks for the hint @N_Molson 👍

[1] Config\Vessels\ScriptPB.cfg
 

N_Molson

Addon Developer
Addon Developer
Donator
Addon List Curator
Joined
Mar 5, 2010
Messages
7,547
Reaction score
689
Points
188
Location
Toulouse
Yes, I'd say the whole LUA API is pretty much functional, but was very under-documented 😉
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,653
Reaction score
170
Points
63
Lua for Orbiter also never got too much love from developers, so I can understand that there were other things more important.
But at lease someone has tried to use it :D ...and immediately a bug was found 😊
 
Top