# LUAThruster groups and Lua

#### Scarecrow

##### New member
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
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

##### New member
Ah Ha! So it does. It works now. Thanks a bundle!

Replies
180
Views
4K
Replies
0
Views
787
Replies
5
Views
621
Replies
21
Views
584
Replies
1
Views
617