[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require and function names
- From: Merick <Merick_TeVaran@...>
- Date: Sat, 21 Jul 2007 15:23:01 -0500
Stefan Brantschen wrote:
As (by default) module foo is loaded into table foo, foo.screen will
be different from bar.screen.
<http://www.lua.org/manual/5.1/manual.html#5.3>
I'm using FreeBasic to make a script interpreter that I call FBlua.
Based on the example from here:
http://lua-users.org/wiki/CreatingBinaryExtensionModules
I made this to test if I could make binary modules with FreeBasic:
'test.bas
#include once "windows.bi"
#include once "lua/lauxlib.bi"
'Pop-up a Windows message box with your choice of message and caption
function lua_msgbox Cdecl (Byval L As lua_State Ptr) As Integer
var message = luaL_checkstring(L, 1)
var caption = luaL_optstring(L, 2, "")
var result = MessageBox(NULL, message, caption, MB_OK)
lua_pushnumber(L, result)
return 1
end function
function luaopen_test Cdecl alias "luaopen_test" (Byval L As lua_State
Ptr) As Integer export
lua_register(L, "msgbox", @lua_msgbox)
return 0
end function
When I use Freebasic to compile that into a windows .dll, I can load it
into FBlua with this script:
require("test")
msgbox("Hey, it worked!", "Lua Message Box")
As you can see, loading my test.dll puts the function directly into the
lua state by itself and not as part of a table...