Return data from Lua to JavaScript

Anonymous

Return data from Lua to JavaScript

Anonymous
Not applicable

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?

Reply
Reply
0 Likes
Reply
391 Views
0 Replies
Replies (0)