MaxAigner Posted October 2, 2015 Share Posted October 2, 2015 hi everyone, I have just tried to implement an DLL into lua with the loadlib command. http://www.lua.org/pil/8.2.html#C-packages they say it should work but it does not Main.lua path = "c:\\windows\\system32\\user32.dll" local GetSystemMetrics = assert(loadlib(path, "GetSystemMetrics")) Error: "Script Error: Attempt to call global 'loadlib' (a nil value) Is there a way of enabling this? It would increase the possibilities of Leadwerks and Lua a Lot and it would allow us to make better leadwerks projects so that leadwerks can get more famous and bought more often!! Quote Link to comment Share on other sites More sharing options...
Olby Posted October 2, 2015 Share Posted October 2, 2015 Have you turned off sandboxing mode? Quote Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64) Link to comment Share on other sites More sharing options...
Rick Posted October 2, 2015 Share Posted October 2, 2015 Tools->Options->uncheck Sandbox Lua. Note this means your game won't work in the LE Game Launcher app then. Quote Link to comment Share on other sites More sharing options...
MaxAigner Posted October 2, 2015 Author Share Posted October 2, 2015 I already did this .. The two lines of code really work for you? Maybe you can test one for me a bit for me it shows the errormessage... Quote Link to comment Share on other sites More sharing options...
Einlander Posted October 3, 2015 Share Posted October 3, 2015 You simply can not use a regular dll for lua. It must be built for lua http://lua-users.org/wiki/CreatingBinaryExtensionModules and http://lua-users.org/wiki/CreatingBinaryExtensionModules . If you really want to use a dll, there are probably ways to do it, but all of them are non trivial. I recommend luajit because leadwerks supports that. http://luajit.org/ext_ffi_tutorial.html Quick and dirty: local ffi = require( 'ffi' ) ffi.cdef [[ int GetSystemMetrics(int test); ]] local user32 = ffi.load(ffi.os == "Windows" and "user32" ) error("Screen Dimensions " .. tostring(user32.GetSystemMetrics(0)) .. "x" .. tostring(user32.GetSystemMetrics(1))) You will be searching through header files. Quote Link to comment Share on other sites More sharing options...
MaxAigner Posted October 3, 2015 Author Share Posted October 3, 2015 ok I will try it out - Thank you Einlander! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.