[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "module" tutorial
- From: "陈果" <guo.chen.cn@...>
- Date: Thu, 13 Apr 2006 22:24:37 +0800
// in your c file
static const luaL_Reg mylib[] = {
/* add any global functions here */
{NULL, NULL}
};
LUAELALIB_API int luaopen_mylib(lua_State *L) {
luaL_register(L, "mylibname", mylib);
/* The mylibname table is now on the stack; add any manipulation of that
table here. */
return 1;
}
Build this file to produce your shared lib named "
mylib.so(dll)" (It seems to have require("mylib") work, the name of the generated shared lib must be the same as the name in luaopen_xxx)
Then in lua script file, write :
LUA_PATH="?.so(dll)" -- Don't need to change the source code of lua core lib
require("mylib")
mylibname.xxx -- use the function registered with mylibname
Hope this can do help to you
2006/4/13, Stockdale, Daire, SOE <stockdaled@soe.sega.co.uk>:
Hello
Can anyone provide a minimalist tutorial on correct use of the "require"
and "module" functions of
5.1 please, especially with reference to
creating a native Lua module? Or direct me to one?
Lots of thanks,
daire
========================================
DISCLAIMER
The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged. Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else.
If you have received this email in error, please notify us immediately by e-mail on administrator@sega.co.uk and then delete the email and any copies. The SEGA Group have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.
========================================
--
Best Regards.
Chen guo
Tongji University, China
Mobile: 13817166264
MSN:
fqy_429@hotmail.com