2 -- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn
3 -- the lua 5.1 loading mechanism is simplicity itself
4 -- for now we need a bridge which will use the correct verion
6 function import_5_0(module)
7 -- imports the file into the program
8 -- for a module 'example'
9 -- this must load 'example.dll' or 'example.so'
10 -- and look for the fn 'Example_Init()' (note the capitalisation)
11 if rawget(_G,module)~=nil then return end -- module appears to be loaded
13 -- capitialising the first letter
14 local c=string.upper(string.sub(module,1,1))
15 local fnname=c..string.sub(module,2).."_Init"
18 -- note: as there seems to be no way in lua to determine the platform
19 -- we will try loading all possible names
20 -- providing one works, we can load
21 for _,suffix in pairs{".dll",".so"} do
22 lib=loadlib(module..suffix,fnname)
27 assert(lib,"error loading module:"..module)
29 lib() -- execute the function: initalising the lib
30 local m=rawget(_G,module) -- gets the module object
31 assert(m~=nil,"no module table found")
34 function import_5_1(module)
38 if string.sub(_VERSION,1,7)=='Lua 5.0' then