Rick Posted April 19, 2015 Share Posted April 19, 2015 I have a Lua table that has functions similar to the App table. I'm able to copy how App is called but I have extra params in my function and not sure how to add those. I'm really not all that familiar with stack type programming. My lua function is: function NoesisHelper:EventRaised(element, event, args) end where element and event are strings and args is a table. The way I call this without filling in those params is: int stacksize = Interpreter::GetStackSize(); Interpreter::GetGlobal("NoesisHelper"); Interpreter::PushString("EventRaised"); // push the Noesis table onto the stack as "self" Interpreter::GetTable(); Interpreter::PushValue(-2); Interpreter::Invoke(1, 1, 0); // restore the stack size Interpreter::SetStackSize(stacksize); What do I do to add 2 string and 1 table param to this function call? Quote Link to comment Share on other sites More sharing options...
Josh Posted April 20, 2015 Share Posted April 20, 2015 The first argument of Invoke is the number of arguments. For OO functions, the table itself counts as an argument. So I believe you would just change that first 1 to 2, and the function argument would get passed. You can add as many arguments as you like. You can get the function results back with Interpreter::PopInt() (or something like that...). Lua can actually return multiple values from a function! Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.