Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Return data from Lua to JavaScript

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
389 Views, 0 Replies

Return data from Lua to JavaScript

Hello

 

I'm calling a Lua function from my Javascript using the following function:

 

raise() {
    if (!this.engineViewportInterops)
          throw new Error('You need to run setup first');

    let args = [this.viewportId].concat(Array.prototype.slice.call(arguments, 0));
    return this.engineViewportInterops.raise.apply(this, args);
}

in my Lua function i print to console and return a dummy value (for now).

 

The console print is working fine, but when I try to retrieve the return value with the following code:

 

this.raise("get_vertex_weights", 1).then( function(w) {
                    console.error("javascript vertex_weights");
                    console.error(w);
});

I can't seem to get any data from the returning promise.

 

 

I've read the documentation and it says: 

The engineViewportInterops object in the example above is a helper that packages communication between the Lua and JavaScript environments. It can help you write a new ViewportBehavior.

 

But it doesn't say if the raise function returns something (other than a promise).

 

Am I doing something wrong? Is there another way to call a Lua function from Javascript and also retrieve the return value?

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report