Orbiter BETA Lua development

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Finally here's the Lua (sub-)Forum!

My current progress and questions regarding the Orbiter Lua API will be posted here.

I will update this 1st post with the current state, as soon as it changed.
New items (since last edit of this post) will be marked green

The attached file represents the current "work in progress" and might still contain some "todo"s.
The attached ZIP contains only files with changes to keep the ZIP-size small.

Almost all the added functions in the current ZIP (2017-12-08) have documentation.
Some of the documentation might not fit the 'LDoc-rules', 'cause I haven't installed LDoc.

The latest update (LuaScript 2019-07-11.zip) only contained documentation changes and a re-layout of the source file locations, therefore no new DLL package was uploaded.

2019-07-11: New source ZIP added, DLL package added
2019-07-08: As per request I've added builds (and sources) for Orbiter 2016, too
2019-07-11: New source ZIP added

For the time being, here are some documentation snippets/hints/details here.

Current status:

Terminal:
- term.clear()

OAPI:
- oapi_get_orbiter_version()
- oapi_get_viewport_size()
- oapi_rand()
- oapi_getcolor()
- oapi.get_annotations()

Vessel-API:
- get_COG_elev()
- get_touchdownpointcount()
- get_touchdownpoints()
- set_touchdownpoints()
- get_clipradius()
- set_albedoRGB()
- set_clipradius()
- set_surfacefrictioncoeff()
- get_status()
- defset_status()
- get_angularacc()
- get_linearmoment()
- get_angularmoment()
- get_globalorientation()
- set_globalorientation()
- is_orbitstabilised()
- is_nonsphericalgravityenabled()
- get_surfaceelevation()
- get_surfacenormal()
- get_smi()
- get_argper()
- get_pedist()
- get_apdist()
- toggle_navmode()
- toggle_rcsmode()
- get_hoverholdaltitude()
- set_hoverholdaltitude()
- version()
- get_dragvector()
- get_forcevector()
- get_torquevector()
- add_force()
- edit_airfoil()
- dockingstatus()
- get_animation()
- del_animationcomponent()
- register_animation()
- unregister_animation()
- set_cameradefaultdirection()
- get_cameradefaultdirection()
- set_cameracatchangle()
- set_camerarotationrange()
- set_camerashiftrange()
- set_cameramovement()[/COLOR]
// coordinate transformations
- shift_centreofmass()
- shiftCG()
- get_superstructureCG()
- get_rotationmatrix()
- set_rotationmatrix()
- globalrot()
- horizonrot()
- horizoninvrot()
- local2global()
- global2local()
- local2rel()
- set_thrusterlevel_singlestep()
// Nosewheel-steering and wheel brakes
- set_nosewheelsteering()
- get_nosewheelsteering()
- set_maxwheelbrakeforce()
- set_wheelbrakelevel()
- get_wheelbrakelevel()
// Instrument panel and virtual cockpit methods
- trigger_panelredrawarea()
- trigger_redrawarea()


Documentation details:

term.clear() :
This method clears the terminal window.

get_touchdownpoints :
This method uses a polymorphic approach.
If the function is called without any parameter, it will return three vectors representing the three touchdownpoints as per the "old" API.
If hte function is called with an index as parameter, it will return the "new" TOUCHDOWNVTX table.
The TOUCHDOWNVTX table contains the following key value pairs:
- "pos" (vector)
- "stiffness" (number)
- "damping" (number)
- "mu" (number)
- "mu_lng" (number)

set_touchdownpoints :
This method uses a polymorphic approach.
If the function is called with three vectors, it will perform the "old" API action.
If the function is called with one list (table) containing at least 3 TOUCHDOWNVTX tables, it will perform the "new" API action.

Example:
Code:
v = vessel.get_focusinterface()

// ----------------------------------------------------------------
p1,p2,p3 = v:get_touchdownpoints()  // OLD, 'cause no index provided
v:set_touchdownpoints(p1, p2, p3)   // OLD, 'cause three vectors provided

// ----------------------------------------------------------------
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,   "     "     "
v:set_touchdownpoints(arr)        // NEW, 'cause table with at least 3 TOUCHDOWNVTX tables given
get_status :
This method can be used to get either the "version 1" VESSELSTATUS or the "version 2" VESSELSTATUS2 table.
The first parameter can be used to distinguish between these two:
- 1: Return "version 1" table
- 2: Return "version 2" table (default if no parameter is given)

The VESSELSTATUS2 table contains the following key value pairs:
- "version" (number) // always 2
- "flag" (number)
- "rbody" (OBJHANDLE)
- "base" (OBJHANDLE)
- "port" (number)
- "status" (number)
- "rpos" (vector)
- "rvel" (vector)
- "vrot" (vector)
- "arot" (vector)
- "surf_lng" (number)
- "surf_lat" (number)
- "surf_hdg" (number)
- "fuel" (list of tables) each containing a "idx" (number) and a "level" (number) member
- "thruster" (list of tables) each containing a "idx" (number) and a "level"(number) member
- "dockinfo" (list of tables) each containing a "idx" (number), "ridx" (number) and a "rvessel" (OBJHANDLE) member
- "xpdr" (number)

The VESSELSTATUS table contains the following key value pairs:
- "rpos" (vector)
- "rvel" (vector)
- "vrot" (vector)
- "arot" (vector)
- "fuel" (number)
- "eng_main" (number)
- "eng_hovr" (number)
- "rbody" (OBJHANDLE)
- "base" (OBJHANDLE)
- "port" (number)
- "status" (number)
- "vdata" (vector) // ignored [1]...[9]
- "fdata" number) // "
- "flag" (number) // "

Example:
Code:
v = vessel.get_focusinterface()
v:get_status()  // returns VESSELSTATUS2 table
v:get_status(1) // returns VESSELSTATUS table
v:get_status(2) // returns VESSELSTATUS2 table
defset_status :
This method can be used to set either a "version 1" VESSELSTATUS or a "version 2" VESSELSTATUS2 table.
The method distinguishes the type just by checking if the value of the ["version"] field in the given table equals 1 or 2.
This method only changes the values that are given in the table, any not mentioned values will not be changed!
Any "unknown" fields will be ignored.

Example:
Code:
v = vessel.get_focusinterface()
vect = { x=1, y=2, z=3 }

v:defset_status("dummy") // <= results in error
v:defset_status({}) // <= results in error (no ["version"] specified)
v:defset_status({ version=2 }) // <= OK, but does not change anything
v:defset_status({ version=1 }) // <= same as above (with "old" VESSELSTATUS)
v:defset_status({ version=2, port=666 }) // <= will only change the port
v:defset_status({ version=2, port=666, foo="bar" }) // <= same as above, all unknown fields will be ignored
v:defset_status({ port=666, arot=vect, version=2 }) // <= OK as long as vect is a VECTOR; the order of the fields is irrelevant
oapi.deflate :
This function deflates (or packs) a string.
This function is called with one string (a bytes array, as Lua strings can contain binary zero as well)

oapi.inflate :
This methods inflates (or unpacks) a packed string that was packed by oapi.deflate() or by the according Orbiter core function.
The new tree-data files for example are packed this way.
This function is called with one string (a bytes array, as Lua strings can contain binary zero as well)

Example:
Code:
local inp = "Hello World!\nHello World!\nHello World!\nHello World!" -- input buffer
local pak = oapi.deflate(inp)
local out = oapi.inflate(pak)

term.out(#inp .. ' => ' .. #pak .. ' => ' .. #out)
term.out("Result: " .. tostring(inp == out))
oapi.get_annotations :
This method returns a list of all currently created annotation handle objects.
This was added mainly as an option while debugging, as newly created annotation handle objects are not automatically deleted when running a script via the "run()" command. So each time a script was run ("run 'script'" rsp. "run('script')") the previous annotatos were not cleared.
Here's an example how this method can be used:
Code:
-- re-use 1st 'old' annotation object (if available)
local noteTop = oapi.get_annotations() or oapi.create_annotation()
This is functionally equal to the following code:
Code:
local noteTop = oapi.get_annotations()
if noteTop == nil then
  noteTop = oapi.create_annotation()
end
...just written a bit more 'cool' :p

Another way of usage (to clear all 'old' annotation objects) would be:
Code:
-- delete any 'old' annotation objects
for key,value in pairs({oapi.get_annotations()}) do
  oapi.del_annotation(value)
end

Note: Current implementation in Orbiter BETA cannot print (via term.out) some of the "more complex" structures, so you might have to explicitly access sub-members like "term.out(vesselstat2.fuel[1])" or "term.out( #vesselstat2.thruster )"
 

Attachments

Last edited:

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
8
Points
0
Website
orbit.medphys.ucl.ac.uk
Cool, we've got a Lua forum now - thanks Josh for setting this up!

Just a quick aside - it's actually "Lua" ("Moon"), not "LUA". It's pedantic I know, but the authors are adamant about it, so we might as well stick to it.

Due to the fact that Martin has to write the documentation, I might add documentation snippets/hints/details here, too.
Oops, I hadn't realised that I still have to do the documentation. Would it help if I provided the html docs for the Lua part of the orbiter.chm file? Unfortunately the entire Lua interface documentation is done manually. I haven't found a way to get doxygen to document the API interface functions. If anybody can come up with a more efficient way please let me know.

In fact, if the Lua interface development is becoming a community effort, maybe we should think about using github or similar.

Another point: the current Lua terminal isn't very well written. I was wondering if there is any code for a generic terminal implementation available that we could use. Something that has basic functionality (input line editing, copy/paste, history, maybe even syntax highlighting and command completion).
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
2,987
Reaction score
102
Points
63
Location
Lisbon
Website
orbiterspaceport.blogspot.com
I'm using Notepad ++ for Lua editing.
There's a syntax checker but of course it ignores all Orbiter functions.

One possibility would be to add the extra Orbiter syntax and commands, I think it's possible.
Does anyone have any experience with this?
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,625
Reaction score
78
Points
123
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Another point: the current Lua terminal isn't very well written. I was wondering if there is any code for a generic terminal implementation available that we could use. Something that has basic functionality (input line editing, copy/paste, history, maybe even syntax highlighting and command completion).
If it could be embedded in somehow, perhaps something like luaprompt could work? It says it's provided as a Lua rock, which pleases me greatly for the lexical comedy while at the same time meaning nothing to me on a package management level.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
35,604
Reaction score
104
Points
153
Location
Langendernbach
I'm using Notepad ++ for Lua editing.
There's a syntax checker but of course it ignores all Orbiter functions.

One possibility would be to add the extra Orbiter syntax and commands, I think it's possible.
Does anyone have any experience with this?
I implemented a Javascript editor in a Java application once with Syntax highlighting and auto-complete for the external API of the application. But I think, for Orbiter, should look at other alternatives first. It was very little code, but very Java specific and was configured by annotations in the script engine binding.

Maybe something like that could be a choice?

https://marketplace.visualstudio.com/items?itemName=trixnz.vscode-lua
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
8
Points
0
Website
orbit.medphys.ucl.ac.uk
Those look interesting - I'll have a look.

If it could be embedded in somehow, perhaps something like luaprompt could work? It says it's provided as a Lua rock, which pleases me greatly for the lexical comedy while at the same time meaning nothing to me on a package management level.
One more important feature I forgot to mention is support for entering commands spanning multiple lines, so that not every command has to be entered on a single line. Without it, complex commands like loops are nearly impossible to enter in the terminal. Since both your suggestions are Lua-specific, I guess they should support this.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
35,604
Reaction score
104
Points
153
Location
Langendernbach
Well, my solution wouldn't work as suitable embedded script terminal, its just a very good code editor.

Wouldn't it be possible in theory to create such a terminal window as plain add-on and have the choice to select which one suits somebody more?
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
8
Points
0
Website
orbit.medphys.ucl.ac.uk
Wouldn't it be possible in theory to create such a terminal window as plain add-on and have the choice to select which one suits somebody more?
Yes, certainly. It's already an addon (Orbitersdk/samples/LuaScript/LuaConsole), but AFAIK nobody has written a replacement so far, so I thought I'd bring it up.
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Would it help if I provided the html docs for the Lua part of the orbiter.chm file?
Noooo, that would mean I would feel guilty when I didn't edit those, too :lol:
Now really: Adding those files to the repository would not only make it possible to add the documentation for each new function directly, it would also make the Solution & Project-files valid ;)

I don't know whether the generator that converts the ".htm" files into the orbiter.chm file would make it into the repository (the Orbiter documentation sources will/should still remain closed-source).
But being able to add/edit the Lua documentation directly would be better. Even if the "compilation" into Orbiter.chm has still to be done by you Martin.
Possible "syntax errors" in those .htm files would have to be fixed by you then.


Another point: the current Lua terminal isn't very well written. I was wondering if there is any code for a generic terminal implementation available that we could use. Something that has basic functionality (input line editing, copy/paste, history, maybe even syntax highlighting and command completion).
Yes, but that could be developed completely independent.
Regarding the "multiple lines" : I think the terminal is just a terminal, not an editor. Usually you don't write complex scripts in a terminal, you open VI or emacs for that :lol:
 
Last edited:

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,625
Reaction score
78
Points
123
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
If you've ever developed in python, think about the utility of ipython - interpreter within the terminal, good syntax support and modular autocompletion
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
I've uploaded my current state of work and updated the 1st post accordingly.

BTW: luaprompt looks interesting.
O.K. now I wonder who's gonna be the first to port it for Orbiters LuaConsole
...ready,...steady,...
 
Last edited:

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
6,856
Reaction score
0
Points
0
Location
Toulouse
Good stuff, please keep it on ! :thumbup:
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
8
Points
0
Website
orbit.medphys.ucl.ac.uk
Regarding the "multiple lines" : I think the terminal is just a terminal, not an editor. Usually you don't write complex scripts in a terminal, you open VI or emacs for that :lol:
One situation where I can see this being useful is if you want to copy a portion of a script and drop it in the terminal window for debugging purposes.

Of course, even better would be an integrated debugger where you have the script and command prompt side by side. You place breakpoints in the script, and then use the command window to inspect or modify variables, etc. I doubt that something like this exists for Lua, and it would be too much effort to implement it just for Orbiter.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
35,604
Reaction score
104
Points
153
Location
Langendernbach
I think a multi-line input isn't the big problem, you could for example also use a scratchpad approach there using something like "\" as indication that this line should be continued.

And maybe display continued lines in the output window first before committing them.

And yes, a full script editor window with breakpoint capability would be the best... but that's also the most complex to implement.

I think a simple terminal window with something like a "Orbiter Lua Shell" would already be good enough, in terms of UI.

For being really posh, there could also be oscilloscope-like view for plotting Lua variables over orbiter time next to it.
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
I have a Orbiter API question (to Martin):

The documentation of VESSEL::GetStatusEx (void *status) says:
Note: In addition, the caller must set the VS_FUELLIST, VS_THRUSTLIST
and VS_DOCKINFOLIST bits in the flag field, if the corresponding
lists are required. Otherwise Orbiter will not produce these lists.
Note: If VS_FUELLIST is specified and the fuel field is NULL, Orbiter
will allocate memory for the list. The caller is responsible for
deleting the list after use
. If the fuel field is not NULL, Orbiter
assumes that a list of sufficient length to store all propellant
resources has been allocated by the caller.
Note: The same applies to the thruster and dockinfo lists.
I've tried to free the memory with
"if (status.fuel) delete[] status.fuel;"
and also tried
"if (status.fuel) free(status.fuel);"
, both giving me a heap corruption.

Can you shed some light into this?

---------- Post added at 23:32 ---------- Previous post was at 20:41 ----------

Phew! Implementing those tables and "lists" via the Lua stack operations is really a PITA:dry:
Nevertheless, some bugs fixed, some functions added and vessel get_status() and defset_status() completed.

Have fun,
Kuddel
 
Last edited:

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Another batch of vessel functions added (slowly but steadily the vessel interface nears completion)
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Another batch of vessel functions added.

A question to those who have experience in writing Lua C API (martin?):
Do you have any recommendation how to implement "reference types" (I mean structures that can be changed anytime and will immediately effect the Orbiter-Core.)
Like the BEACONLIGHTSPEC structure used with VESSEL::AddBeacon()
I think "metatables" and "__index" and all its voodoo ( ;) ) is the way to go, but I don't feel I could do this at the moment...
A working (AddBeacon) C++ example would be perfect

---------- Post added 25-10-17 at 00:05 ---------- Previous post was 24-10-17 at 23:47 ----------

....aaaand as I wrote a script for myself to clearly overview all missing / not missing VESSEL API methods. Here's the result:
Code:
[+] ActivateNavmode                         set_navmode
[+] AddAnimationComponent                   add_animationcomponent
[-] AddAnimComp                             -- deprecated/obsolete
[-] AddAttExhaustMode                       -- deprecated/obsolete
[-] AddAttExhaustRef                        -- deprecated/obsolete
[ ] AddBeacon
[+] AddExhaust                              add_exhaust
[-] AddExhaustRef                           -- deprecated/obsolete
[+] AddExhaustStream                        add_exhauststream
[+] AddForce                                add_force
[+] AddMesh                                 add_mesh
[ ] AddParticleStream
[+] AddPointLight                           add_pointlight
[ ] AddReentryStream
[+] AddSpotLight                            add_spotlight
[+] AttachChild                             attach_child
[+] AttachmentCount                         get_attachmentcount
[ ] ClearAirfoilDefinitions
[+] ClearAttachments                        clear_attachments
[-] ClearAttExhaustRefs                     -- deprecated/obsolete
[ ] ClearBeacons
[ ] ClearControlSurfaceDefinitions
[ ] ClearDockDefinitions
[-] ClearExhaustRefs                        -- deprecated/obsolete
[+] ClearLightEmitters                      clear_lightemitters
[+] ClearMeshes                             clear_meshes
[+] ClearPropellantResources                clear_propellantresources
[+] ClearThrusterDefinitions                clear_thrusters
[ ] ClearVariableDragElements
[ ] CopyMeshFromTemplate
[ ] Create
[ ] CreateAirfoil
[ ] CreateAirfoil2
[+] CreateAirfoil3                          create_airfoil
[+] CreateAnimation                         create_animation
[+] CreateAttachment                        create_attachment
[ ] CreateControlSurface
[ ] CreateControlSurface2
[+] CreateControlSurface3                   create_controlsurface
[+] CreateDock                              create_dock
[+] CreatePropellantResource                create_propellantresource
[+] CreateThruster                          create_thruster
[+] CreateThrusterGroup                     create_thrustergroup
[ ] CreateVariableDragElement
[+] DeactivateNavmode                       set_navmode
[+] DefSetState                             defset_status
[+] DefSetStateEx                           defset_status
[+] DelAirfoil                              del_airfoil
[+] DelAnimation                            del_animation
[+] DelAnimationComponent                   del_animationcomponent
[+] DelAttachment                           del_attachment
[ ] DelBeacon
[ ] DelControlSurface
[+] DelDock                                 del_dock
[+] DelExhaust                              del_exhaust
[-] DelExhaustRef                           -- deprecated/obsolete
[ ] DelExhaustStream
[+] DelLightEmitter                         del_lightemitter
[+] DelMesh                                 del_mesh
[+] DelPropellantResource                   del_propellantresource
[+] DelThruster                             del_thruster
[-] DelThrusterGroup                        -- deprecated/obsolete
[+] DetachChild                             detach_child
[ ] Dock
[+] DockCount                               get_dockcount
[+] DockingStatus                           dockingstatus
[+] EditAirfoil                             edit_airfoil
[+] EnableIDS                               enable_ids
[+] EnableTransponder                       enable_transponder
[+] GetADCtrlMode                           get_adcmode
[+] GetAirfoilParam                         edit_airfoil
[+] GetAirspeed                             get_airspeed
[+] GetAirspeedVector                       get_airspeedvector
[+] GetAltitude                             get_altitude
[+] GetAngularAcc                           get_angularacc
[+] GetAngularMoment                        get_angularmoment
[+] GetAngularVel                           get_angvel
[+] GetAnimation                            get_animation
[ ] GetAnimPtr
[+] GetAOA                                  get_aoa
[+] GetApDist                               get_apdist
[+] GetArgPer                               get_argper
[+] GetAtmDensity                           get_atmdensity
[+] GetAtmPressure                          get_atmpressure
[+] GetAtmRef                               get_atmref
[+] GetAtmTemperature                       get_atmtemperature
[+] GetAttachmentHandle                     get_attachmenthandle
[+] GetAttachmentId                         get_attachmentid
[+] GetAttachmentIndex                      get_attachmentindex
[+] GetAttachmentParams                     get_attachmentparams
[+] GetAttachmentStatus                     get_attachmentstatus
[ ] GetAttitudeLinLevel
[+] GetAttitudeMode                         get_rcsmode
[ ] GetAttitudeRotLevel
[+] GetBank                                 get_bank
[-] GetBankMomentScale                      -- deprecated/obsolete
[ ] GetBeacon
[ ] GetCameraDefaultDirection
[+] GetCameraOffset                         get_cameraoffset
[+] GetClassName                            get_classname
[+] GetClipRadius                           get_clipradius
[+] GetCOG_elev                             get_COG_elev
[+] GetControlSurfaceLevel                  get_adclevel
[+] GetCrossSections                        get_crosssections
[+] GetCW                                   get_cw
[+] GetDamageModel                          get_damagemodel
[ ] GetDefaultPropellantResource
[ ] GetDevMesh
[+] GetDockHandle                           get_dockhandle
[+] GetDockParams                           get_dockparams
[+] GetDockStatus                           get_dockstatus
[ ] GetDrag
[+] GetDragVector                           get_dragvector
[+] GetDynPressure                          get_dynpressure
[ ] GetEditorModule
[+] GetElements                             get_elements
[+] GetEmptyMass                            get_emptymass
[+] GetEnableFocus                          get_enablefocus
[-] GetEngineLevel                          -- deprecated/obsolete
[ ] GetEquPos
[+] GetExhaustCount                         get_exhaustcount
[ ] GetExhaustLevel
[ ] GetExhaustSpec
[+] GetFlightModel                          get_flightmodel
[+] GetFlightStatus                         is_landed
[+] GetForceVector                          get_forcevector
[ ] GetFuelMass
[ ] GetFuelRate
[+] GetGlobalOrientation                    get_globalorientation
[+] GetGlobalPos                            get_globalpos
[+] GetGlobalVel                            get_globalvel
[+] GetGravityGradientDamping               get_gravitygradientdamping
[+] GetGravityRef                           get_gravityref
[+] GetGroundspeed                          get_groundspeed
[+] GetGroundspeedVector                    get_groundspeedvector
[+] GetGroupThruster                        get_groupthrustercount
[+] GetGroupThrusterCount                   get_groupthrustercount
[+] GetHandle                               get_handle
[-] GetHorizonAirspeedVector                -- deprecated/obsolete
[+] GetHoverHoldAltitude                    get_hoverholdaltitude
[+] GetIDS                                  get_ids
[ ] GetISP
[ ] GetLift
[+] GetLiftVector                           get_liftvector
[+] GetLightEmitter                         get_lightemitter
[+] GetLinearMoment                         get_linearmoment
[+] GetMachNumber                           get_machnumber
[-] GetMainThrustModPtr                     -- deprecated/obsolete
[ ] GetManualControlLevel
[+] GetMass                                 get_mass
[ ] GetMaxFuelMass
[-] GetMaxThrust                            -- deprecated/obsolete
[ ] GetMesh
[+] GetMeshCount                            get_meshcount
[ ] GetMeshName
[+] GetMeshOffset                           get_meshoffset
[ ] GetMeshTemplate
[ ] GetMeshVisibilityMode
[+] GetName                                 get_name
[+] GetNavChannel                           get_navchannel
[+] GetNavCount                             get_navcount
[+] GetNavmodeState                         get_navmode
[-] GetNavRecv                              -- deprecated/obsolete
[ ] GetNavRecvFreq
[+] GetNavSource                            get_navsource
[+] GetNosewheelSteering                    get_nosewheelsteering
[+] GetPeDist                               get_pedist
[+] GetPitch                                get_pitch
[+] GetPitchMomentScale                     get_pitchmomentscale
[+] GetPMI                                  get_pmi
[+] GetPropellantCount                      get_propellantcount
[+] GetPropellantEfficiency                 get_propellantefficiency
[+] GetPropellantFlowrate                   get_propellantflowrate
[+] GetPropellantHandleByIndex              get_propellanthandle
[+] GetPropellantMass                       get_propellantmass
[+] GetPropellantMaxMass                    get_propellantmaxmass
[+] GetRelativePos                          get_relativepos
[+] GetRelativeVel                          get_relativevel
[+] GetRotationMatrix                       get_rotationmatrix
[+] GetRotDrag                              get_rotdrag
[-] GetShipAirspeedVector                   -- deprecated/obsolete
[+] GetSize                                 get_size
[+] GetSlipAngle                            get_slipangle
[+] GetSMi                                  get_smi
[+] GetStatus                               get_status
[+] GetStatusEx                             get_status
[+] GetSuperstructureCG                     get_superstructureCG
[ ] GetSupervessel
[ ] GetSupervesselCG
[+] GetSurfaceElevation                     get_surfaceelevation
[+] GetSurfaceNormal                        get_surfacenormal
[+] GetSurfaceRef                           get_surfaceref
[+] GetThrusterCount                        get_thrustercount
[+] GetThrusterDir                          get_thrusterdir
[+] GetThrusterGroupHandle                  get_thrustergrouphandle
[+] GetThrusterGroupLevel                   get_thrustergrouplevel
[+] GetThrusterHandleByIndex                get_thrusterhandle
[+] GetThrusterIsp                          get_thrusterisp0
[+] GetThrusterIsp0                         get_thrusterisp0
[+] GetThrusterLevel                        get_thrusterlevel
[+] GetThrusterMax                          get_thrustermax0
[+] GetThrusterMax0                         get_thrustermax0
[ ] GetThrusterMoment
[+] GetThrusterRef                          get_thrusterpos
[+] GetThrusterResource                     get_thrusterresource
[+] GetThrustVector                         get_thrustvector
[+] GetTorqueVector                         get_torquevector
[+] GetTotalPropellantFlowrate              get_totalpropellantflowrate
[+] GetTotalPropellantMass                  get_totalpropellantmass
[+] GetTouchdownPoint                       get_touchdownpoints
[+] GetTouchdownPointCount                  get_touchdownpointcount
[+] GetTouchdownPoints                      get_touchdownpoints
[+] GetTransponder                          get_transponder
[+] GetTrimScale                            get_trimscale
[ ] GetUserThrusterGroupCount
[+] GetUserThrusterGroupHandleByIndex       get_thrustergrouphandlebyindex
[+] GetWeightVector                         get_weightvector
[+] GetWheelbrakeLevel                      get_wheelbrakelevel
[+] GetWingAspect                           get_wingaspect
[+] GetWingEffectiveness                    get_wingeffectiveness
[+] GetYaw                                  get_yaw
[+] GetYawMomentScale                       get_yawmomentscale
[+] Global2Local                            global2local
[+] GlobalRot                               globalrot
[+] GroundContact                           get_groundcontact
[+] HorizonInvRot                           horizoninvrot
[+] HorizonRot                              horizonrot
[-] IncEngineLevel                          -- deprecated/obsolete
[+] IncThrusterGroupLevel                   inc_thrustergrouplevel
[+] IncThrusterGroupLevel_SingleStep        inc_thrustergrouplevel_singlestep
[+] IncThrusterLevel                        inc_thrusterlevel
[+] IncThrusterLevel_SingleStep             inc_thrusterlevel_singlestep
[+] InitNavRadios                           init_navradios
[+] InsertMesh                              insert_mesh
[+] LightEmitterCount                       get_lightemittercount
[+] Local2Global                            local2global
[+] Local2Rel                               local2rel
[ ] MeshgroupTransform
[ ] MeshModified
[+] NonsphericalGravityEnabled              is_nonsphericalgravityenabled
[+] OrbitStabilised                         is_orbitstabilised
[-] ParseScenarioLine                       -- deprecated/obsolete
[ ] ParseScenarioLineEx
[ ] Playback
[ ] RecordEvent
[ ] Recording
[+] RegisterAnimation                       register_animation
[-] RegisterAnimSequence                    -- deprecated/obsolete
[-] SaveDefaultState                        -- deprecated/obsolete
[+] SendBufferedKey                         send_bufferedkey
[+] SetADCtrlMode                           set_adcmode
[+] SetAlbedoRGB                            set_albedoRGB
[+] SetAngularVel                           set_angvel
[+] SetAnimation                            set_animation
[-] SetAnimState                            -- deprecated/obsolete
[+] SetAttachmentParams                     set_attachmentparams
[ ] SetAttitudeLinLevel
[+] SetAttitudeMode                         set_rcsmode
[ ] SetAttitudeRotLevel
[-] SetBankMomentScale                      -- deprecated/obsolete
[ ] SetCameraCatchAngle
[+] SetCameraDefaultDirection               set_cameradefaultdirection
[ ] SetCameraMovement
[+] SetCameraOffset                         set_cameraoffset
[ ] SetCameraRotationRange
[ ] SetCameraShiftRange
[+] SetClipRadius                           set_clipradius
[-] SetCOG_elev                             -- deprecated/obsolete
[+] SetControlSurfaceLevel                  set_adclevel
[+] SetCrossSections                        set_crosssections
[+] SetCW                                   set_cw
[ ] SetDefaultPropellantResource
[ ] SetDockMode
[+] SetDockParams                           set_dockparams
[+] SetElements                             set_elements
[+] SetEmptyMass                            set_emptymass
[+] SetEnableFocus                          set_enablefocus
[-] SetEngineLevel                          -- deprecated/obsolete
[-] SetExhaustScales                        -- deprecated/obsolete
[ ] SetFuelMass
[+] SetGlobalOrientation                    set_globalorientation
[+] SetGravityGradientDamping               set_gravitygradientdamping
[+] SetHoverHoldAltitude                    set_hoverholdaltitude
[+] SetIDSChannel                           set_idschannel
[ ] SetISP
[ ] SetLiftCoeffFunc
[ ] SetMaxFuelMass
[-] SetMaxThrust                            -- deprecated/obsolete
[+] SetMaxWheelbrakeForce                   set_maxwheelbrakeforce
[ ] SetMeshVisibilityMode
[-] SetMeshVisibleInternal                  -- deprecated/obsolete
[+] SetNavChannel                           set_navchannel
[-] SetNavRecv                              -- deprecated/obsolete
[+] SetNosewheelSteering                    set_nosewheelsteering
[+] SetPitchMomentScale                     set_pitchmomentscale
[+] SetPMI                                  set_pmi
[+] SetPropellantEfficiency                 set_propellantefficiency
[+] SetPropellantMass                       set_propellantmass
[+] SetPropellantMaxMass                    set_propellantmaxmass
[ ] SetReentryTexture
[+] SetRotationMatrix                       set_rotationmatrix
[+] SetRotDrag                              set_rotdrag
[+] SetSize                                 set_size
[+] SetSurfaceFrictionCoeff                 set_surfacefrictioncoeff
[+] SetThrusterDir                          set_thrusterdir
[+] SetThrusterGroupLevel                   set_thrustergrouplevel
[+] SetThrusterIsp                          set_thrusterisp
[+] SetThrusterLevel                        set_thrusterlevel
[+] SetThrusterLevel_SingleStep             set_thrusterlevel_singlestep
[+] SetThrusterMax0                         set_thrustermax0
[+] SetThrusterRef                          set_thrusterpos
[+] SetThrusterResource                     set_thrusterresource
[+] SetTouchdownPoints                      set_touchdownpoints
[+] SetTransponderChannel                   set_transponderchannel
[+] SetTrimScale                            set_trimscale
[+] SetVisibilityLimit                      set_visibilitylimit
[+] SetWheelbrakeLevel                      set_wheelbrakelevel
[+] SetWingAspect                           set_wingaspect
[+] SetWingEffectiveness                    set_wingeffectiveness
[+] SetYawMomentScale                       set_yawmomentscale
[+] ShiftCentreOfMass                       shift_centreofmass
[+] ShiftCG                                 shiftCG
[+] ShiftMesh                               shift_mesh
[+] ShiftMeshes                             shift_meshes
[ ] ThrusterGroupDefined
[+] ToggleAttitudeMode                      toggle_rcsmode
[+] ToggleNavmode                           toggle_navmode
[+] TriggerPanelRedrawArea                  trigger_panelredrawarea
[+] TriggerRedrawArea                       trigger_redrawarea
[+] Undock                                  undock
[+] UnregisterAnimation                     unregister_animation
[+] Version                                 version
Legend:
1st column:
[ ] not (yet) available in Lua
[x] available in Lua
[-] depricated or obsolete (may or may not be available in Lua)
2nd column:
Orbiter C-Method name
3rd column:
Lua vessel function name


Should this maybe added to the 1st post?

---------- Post added at 23:33 ---------- Previous post was at 00:05 ----------

Hi Martin,

I have a question about your ASSERT_xxx macros.

Am I right, that the ASSERT_xxx macros and the ASSERT_MTDxxx macros only differ in the presentation of the parameter index (in case the assertion fails)?
I assume that 'MTD' stands for "method"?
If that is true, I have to check that I use the ASSERT_MTDxxx macros in the vessel methods, so that they report any parameter failure with the correct index...
 
Last edited:

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,352
Reaction score
8
Points
0
Website
orbit.medphys.ucl.ac.uk
I have a question about your ASSERT_xxx macros.

Am I right, that the ASSERT_xxx macros and the ASSERT_MTDxxx macros only differ in the presentation of the parameter index (in case the assertion fails)?
I assume that 'MTD' stands for "method"?
If that is true, I have to check that I use the ASSERT_MTDxxx macros in the vessel methods, so that they report any parameter failure with the correct index...
Yes, that's correct. Since methods (with ':' syntax) have a hidden first parameter self that appears in the Lua stack of the C++ interface function but not in the Lua call, I introduced the ASSERT_MTDxxx calls to avoid confusion when reporting the parameter index. And yes, MTD stands for method.
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Thanks for the clarification Martin,

but since you are here ( :p ) you could maybe clarify something else, too:

Some vessel methods exit with an assertion, others return nil --in case of an invalid vessel.
Is there any reason behind this, or did you just changed your mind in between?

And in case there's no real reason for the different behavior, what behavior should I prefer.


Asserting method:
PHP:
int Interpreter::v_get_gravitygradientdamping (lua_State *L)
{
	VESSEL *v = lua_tovessel (L,1);
	ASSERT_SYNTAX(v, "Invalid vessel object");
	double ggd = v->GetGravityGradientDamping();
	lua_pushnumber(L,ggd);
	return 1;
}
Nil returning method:
PHP:
int Interpreter::v_get_emptymass (lua_State *L)
{
	VESSEL *v = lua_tovessel(L);
	if (v) {
		lua_pushnumber (L, v->GetEmptyMass());
		GetInterpreter(L)->term_echo(L);
	} else lua_pushnil (L);
	return 1;
}
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,500
Reaction score
28
Points
48
Another batch of vessel functions added
 
Top