lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Stefan Brantschen wrote:

As (by default) module foo is loaded into table foo, foo.screen will be different from bar.screen.

I'm using FreeBasic to make a script interpreter that I call FBlua.

Based on the example from here:
I made this to test if I could make binary modules with  FreeBasic:


#include once ""
#include once "lua/"

'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:


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...