Skip to content

Instantly share code, notes, and snippets.

@sourcevault
Last active June 26, 2018 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sourcevault/5947542abeed995769daab86789a8064 to your computer and use it in GitHub Desktop.
Save sourcevault/5947542abeed995769daab86789a8064 to your computer and use it in GitHub Desktop.
basic C module in Lua with Luarocks
sleep = require ("sourcevault/sleep")
sleep.hello()
#include <lua.h>
int sleep_hello(lua_State* L) {
lua_pushliteral(L, "Hello, world!");
return 1;
}
int luaopen_sleep(lua_State* L) {
lua_newtable(L);
lua_pushcfunction(L, sleep_hello);
lua_setfield(L, -2, "hello");
return 1;
}
package = "sourcevault/sleep"
version = "1.0-1"
source = {
url = "." -- not online yet!
}
build = {
type = "builtin",
modules = {
sourcevault =
{sleep = "sleep.c"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment