Closed stiggy87 closed 2 years ago
Nevermind. I forgot to add in more libraries, especially the sol::lib::string
.
On that note, is there a way to blanket open all libraries, or is it strictly explicit?
Gmatch is a part of the string library. You need to open sol::lib::string
in order to use it. You can also open all libraries with lua.open_libraries()
Also, vars.gmatch
should be vars:gmatch
as you are calling it like a method.
Running into a weird issue, where I am trying to build a very simple "Lua console" that I can use to do live-debugging/updates of a much bigger project I'm working on. In the process, I created a simple Lua file filled with functions and all the functions will take an argument as a string, where I will do a getopt type function to parse it out, complete the task and return a string of results, or pass/fail, etc.
Running the Lua manually gets the results I want, but when I call it from the C++, it always returns nil. I'm assuming I'm messing something up on the stack, but I'm not sure. You can see an example of the code here: https://godbolt.org/z/a5qrxeE6h
I did create a single sol2 header since that's most likely how I will end up deploying things, but the example above doesn't do that.
Compilation details: compiler: gcc 9.4 with C++17 w/ Visual Studio Code OS: Ubuntu 20.04 (WSL2) Lua 5.2/5.3
Any help would be great!