|
LibraryExample
Very simple Lua library example in D
Featured IntroductionThis will only work for those who use DLua directly, as in, this won't help you with building .dll/.so's for the Lua interpreter. Code
module example;
import dlua.all;
import std.stdio;
import lualibrary;
void main()
{
lua_State* L = luaL_newstate();
luaL_openlibs(L);
lua_pushcfunction(L, &luaopen_example);
lua_pcall(L, 0, 0, 0);
luaL_dostring(L, `print(example.func())`);
lua_close(L);
}module lualibrary;
import dlua.all;
private luaL_Reg[] example = [
{"func", &func},
{null, null}
];
private extern (C) int func (lua_State* L)
{
lua_pushstring(L, "aargh!!!");
return 1;
}
extern (C) int luaopen_example (lua_State* L)
{
luaL_register(L, "example", example.ptr);
return 1;
}
|
► Sign in to add a comment
function dlua.lua.lua_pushcfunction (void,int()(void L)) does not match parameter types (void,int(C )(void L))
wtf?