2
How do I run a Lua code block inside a C function++?
The idea would be something like:
int main() {
tipodavariavel script;
script << "print('Ola mundo')";
executar(script);
return 0;
}
2
How do I run a Lua code block inside a C function++?
The idea would be something like:
int main() {
tipodavariavel script;
script << "print('Ola mundo')";
executar(script);
return 0;
}
2
This is an example of basic code to run a script Lua. Note that essentially C syntax is used:
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
int main() {
lua_State *L = lua_open();
luaL_openlibs(L);
luaL_dostring(L, "print('Ola mundo')");
lua_close(L);
}
I put in the Github for future reference.
To compile you must use something like this using GCC/Mingw:
g++ -o interpetadorlua.cpp -llua -ldl
Generally speaking this is, I don’t know if you need anything specific.
List of multiple libraries with examples that can help in integration in many ways if you want higher-level and abstract ways to address the problem.
Browser other questions tagged c++ lua interoperability
You are not signed in. Login or sign up in order to post.
I need to run inline.
– Gabriel Sales
What do you call inline?
– Maniero
I edited the question. Would run straight from there without using another file.
– Gabriel Sales
luaL_loadstring
does not execute code. UseluaL_dostring
.– lhf