14-07-2021

- Wed Jun 10, 2015 6:20 am

  1. Call Lua From Chinese
  2. Lua C Function
  3. C++ With Lua

In this tutorial we go over calling Lua functions from C.Twitter: https://twitter.com/KarmaKilledTC. Basically, there's several entry points into these weapons and scripts that are called by C. For instance: local function onWeaponFired -do stuff. Should be called when the player hits the attack button. However, I can't figure out a way to call a local function from C, and I want global memory to be shared across each Lua weapon.

#20027 I am re-compiling the NodeMCU LUA successfully as I am trying to package several LUA calls together and mix them with C API calls. Has anybody tried to call a NodeMCU LUA function like wifi.ap.getmac from C? Again, I am trying to mix C and LUA and the stuff compiles fine but it makes the module crash and go into a loop here is an example of the code I'm using:C++ with lua
void get_mac_add( lua_State* L)
{

Call Lua From Chinese

lua_State* L;

Lua C Function

lua_getglobal(L, 'wifi.ap.getmac');
lua_pcall(L, 0, 1, 0);
const char * macadd = lua_tostring(L, -1);
INFO(macadd); // macro to print to UART
}
Any help will be much appreciated.
Thanks

C++ With Lua


Horacio.