Question Implementing XRSound in Lua?

Well. So, any ideas how to play different songs for internal and external views for a Lua based vessel are welcome.
"Returns:<br>handle or nil handle to the current camera target (i.e. the object the camera is pointing at in external mode, or the handle of the vessel in cockpit mode)"
Could you use that? (I know zero about Lua!)
 
The Lua API is still missing a bunch of stuff, notably oapiCameraInternal which could help you now.
 
Thanks, it really can help. Is it implemented in Lua? Maybe I search it in the wrong place?:

Без імені.png
 
Adding missing API features to Lua is not that hard (as Open Orbiter now is ... open ;) )
Whithout me being able to test this, adding oapiCameraInternal is just editing 2 files basically:
1. In LuaScript/LuaInterpreter/Interpreter.h (find the 'correct' place to put this - where the other 'camera' function definitions live)
C++:
// ...

    // Camera functions
    static int oapi_camera_internal (lua_State *L);
   // ...

2. In LuaScript/LuaInterpreter/Interpreter.cpp (In body of method LoadAPI) add the lookup:
C++:
void Interpreter::LoadAPI ()
{
  // ...

        // Camera functions
        {"camera_internal", oapi_camera_internal},

  // ...
}
...and further down (find the matching other camara-related functions) add the body and Documentation as well:
C++:
/***
Returns flag to indicate internal/external camera mode.

@function camera_internal
@treturn bool _true_ indicates an internal camera mode, i.e. the camera is
   located inside a vessel cockpit. In this case, the camera target is always
   the current focus object.
   _false_ indicates an external camera mode, i.e. the camera points toward an
   object from outside. The camera target may be a vessel, planet, spaceport,
   etc.
*/
int Interpreter::oapi_camera_internal (lua_State *L)
{
    lua_pushboolean (L, oapiCameraInternal() ? 1:0);
    return 1;
}

And of course: Test it!

All of the code above was just typed "in the blind", so there might by one or two syntax errors ;)
 
Thanks. I could test this function in a Lua script, but maybe anyone who understands programming better than me (and can detect possible syntax errors) could edit and upload these Interpreter.h and Interpreter.cpp.
 
My expertise in Lua is very low, but if you could write a Lua Test and add it to the automatic tests for Lua it would be very helpful.
In here: Script/Tests/GeneralApiTest.lua
It could be "commented out" in the first step, so as soon as somebody implements the feature (in C++) the test can immediately be enabled to check if it's working.
Even if you just post the Lua Script code here, would be a great help.
 
I rather meant that I can try to use oapiCameraInternal command in my Lua script, but I don't know how to write a Lua test file...

Is there an actual table that shows what the functions are released in Lua? Something like here:

But I don't see oapiCameraInternal here. Do I understand correctly that oapiCameraInternal is absent for now in Lua?
 
As Gondos said: This feature is not (yet) available in Lua.

For whom it might concern, here's a little description:
All the API methods first only exists in "C++ Land".
For every C++ API method a "Translation" into "Lua Land" has to be implemented.
That Translation however has to be implemented in C++. Only after that, the specific functionality is available in "Lua Land".
See it as a dictionary that has all the words in french, but not all words have (yet) an english translation available ;)
 
Back
Top