It was thus said that the Great 'Kritzel Kratzel' via lua-l once stated:
> I have written a small C-library (Windows DLL) for implementing the *ping*
> command for Lua, in which functions are registered as metamethods in the
> usual way. I like to extend this code with a version string feature:
>
> lp = require "luaping"
> print(lp._VERSION)
> LuaPing 1.0
>
> Is it possible to do this via the C API of Lua? If yes, how do I do this?
>
> Thanks,
> KK
>
> DLL int luaopen_luaping(lua_State *L){
> luaL_newlib(L, luaping_funcs);
> luaL_newlib(L, luaping_metamethods);
> lua_setmetatable(L, -2);
> return 1;
> }
Yes, thusly:
DLL int luaopen_luaping(lua_State *L){
luaL_newlib(L,luaping_funcs);
luaL_newlib(L,luaping_metamethods);
lua_setmetatable(L, -2);
lua_pushlstring(L,"LuaPing 1.0");
lua_setfield(L,-2,"_VERSION");
return 1;
}
-spc