You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can't! Code written in Lua cannot access general raw Erlang data structures, it can only access data in the right formats passed in the right format and will only return data in that format. It is up to the caller to encode/decode the data.
If you check the documentation for the luerl module you will see that there are usually 2 versions of many of the access functions, those that encode/decode for you and those that don't encode/decode and pass the internal Luerl formats in and out. Those don't encode/decode have names which end in 1. So for example the is a luerl:call_function/3 which encodes/decodes and a luerl:call_function1/3 which does not. No, the naming convention is not that good. 😄
When you called luerl:load/2 it compiled the string and returned the generated chunk in F. Then when you called that chunk with luerl:call/2 it just called the chunk and all the chunk did was load the function into the state. And that returned Lua nil which became the empty list.
You will find all the current Luerl documentation in the github Luerl wiki which also contains a lot of examples. I am in the process of migrating that documentation to the repo itself so it will be included when you download Luerl. So far I have only done the interface modules luerl, luerl_new and luerl_sandbox but I am working on it.
The luerl_new module contains the new standard interface which will in a future major release replace luerl which will then be kept in luerl_old. I think the new interface is much cleaner.
Hopefully this will help you a bit. Check the wiki and look in the examples directory for a bunch of examples and test cases. Not all are easy to understand I am afraid.
Tyler, there is also a Luerl slack workspace mentioned in the README and the wiki as well. And discord as well for that matter.
I'm trying to call a Lua function with Erlang terms like maps.
I've had 2 ideas so far:
But this only ever returns an empty list rather than the
[1, 2, 3]
or#tref
output I'd expectWhat is the intended method of calling lua methods from erlang with a set of given arguments?
The text was updated successfully, but these errors were encountered: