diff options
author | Oliver Schneider <oliver@assarbad.net> | 2012-12-13 08:30:21 +0400 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2012-12-13 08:30:21 +0400 |
commit | 57a15c2d0244a3fbef2609a45b40be40a0cc39dd (patch) | |
tree | 0cc77d9794edc1d23ccee941fa963a9a9f38cbec /sandbox | |
parent | 6437befd3a917da06898f150e724ade8a1693ec9 (diff) |
- First working implementation, requires better error handling, though
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/luaconf/hello.lua | 7 | ||||
-rw-r--r-- | sandbox/luaconf/lua_conf.cpp | 6 | ||||
-rw-r--r-- | sandbox/luaconf/lua_conf.lua | 12 |
3 files changed, 17 insertions, 8 deletions
diff --git a/sandbox/luaconf/hello.lua b/sandbox/luaconf/hello.lua index 7b5f712..16cac19 100644 --- a/sandbox/luaconf/hello.lua +++ b/sandbox/luaconf/hello.lua @@ -1,3 +1,6 @@ -module(..., package.seeall)
+module(..., package.seeall)
-print "Hello world"
+-- Declare the functions you want in your module
+function hello()
+ print ("Hello WORLD, module")
+end
diff --git a/sandbox/luaconf/lua_conf.cpp b/sandbox/luaconf/lua_conf.cpp index f376fe3..a8951fd 100644 --- a/sandbox/luaconf/lua_conf.cpp +++ b/sandbox/luaconf/lua_conf.cpp @@ -76,12 +76,12 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) lua_State* L = luaWDS_open();
if(L)
{
- //fprintf(stderr, "[STACK TOP] %i (line %i)\n", lua_gettop(L), __LINE__);
enumerateEmbeddedLuaScripts(L);
- int ret = luaL_dofile(L, "..\\lua_conf.lua");
+ int ret;
+ ret = luaL_dofile(L, "lua_conf.lua");
if(ret)
{
- lua_pop(L, 1); /* pop error message from the stack */
+ luaL_error(L, "Failed to load lua_conf.lua (%d)", ret);
lua_close(L);
return EXIT_FAILURE;
}
diff --git a/sandbox/luaconf/lua_conf.lua b/sandbox/luaconf/lua_conf.lua index 591a841..07a1e2c 100644 --- a/sandbox/luaconf/lua_conf.lua +++ b/sandbox/luaconf/lua_conf.lua @@ -26,10 +26,16 @@ end for k,v in pairs(winres.scripts) do
package.preload[k:lower()] = function(...)
- return winres.c_loader(k:upper())
+ return winres.c_loader(k:lower())
end
- package.preload[k:upper()] = package.preload[k:lower()]
end
+table.foreach(package, print)
dumptable('package.preload', package.preload)
-require "helloworld"
+dumptable('winreg', winreg)
+x = require "helloworld"
dumptable('package.loaded', package.loaded)
+dumptable('package.loaded.helloworld', x)
+x.hello()
+
+--
+
|