LUA Thruster groups and Lua

Scarecrow

Member
Joined
Feb 10, 2008
Messages
272
Reaction score
1
Points
18
Location
USA
So I'm back (at least temporarily) after a long hiatus. Looks like times have been good in my absence. Orbiter 2010 is awesome.:tiphat:

I've been playing with Lua a bit, because I want to experiment with writing autopilots, but I don't want to deal with c++. Unfortunately I've been having trouble selecting any thruster groups except the main engines. I've written a little testing MFD that does this:

Code:
-- vi is the focused vessel (result of calling vessel.get_focusinterface())
-- thgrp is a user specified integer, which selects a thruster group
thrust = vi:get_thrustergrouplevel(vi:get_thrustergrouphandlebyindex(thgrp))
-- now write the value of thrust to the MFD display

This should allow me to work out the correspondence between numbers and thrusters, by changing thgrp and then firing various engines. However, I've tested this in the stock DG, the Shuttle-A, and the Shuttle-PB, and all of the numbers (positive and negative (and I'm surprised negative numbers don't crash it)) seem to correspond to the main engines. The only exception I've found so far is that in the Shuttle-A, 0 is the aux engines. What's going on here? Am I doing it wrong? Is the Lua api incomplete or buggy? If it would help, I can post the source for my testing MFD. It's not too long.

Thanks!
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
From the Lua documentation for get_thrustergrouphandlebyindex:
Use this method only to retrieve handles for nonstandard thruster groups. For standard groups, use v:get_thrustergrouphandle instead.
Alternatively, you can use the integer ID directly with get_thrustergrouplevel, i.e.
Code:
thrust = vi:get_thrustergrouplevel(thgrp)
I admit that the use of two separate functions for retrieving standard and user-defined thruster group handles is cumbersome and prone to coding errors. I'll see if I can consolidate them into a single function, although this may be tricky, because standard IDs and user IDs overlap.
 

Scarecrow

Member
Joined
Feb 10, 2008
Messages
272
Reaction score
1
Points
18
Location
USA
Ah Ha! So it does. It works now. Thanks a bundle!
 
Top