NewPalette Posted August 26, 2014 Share Posted August 26, 2014 I'm just starting out with scripting in Leadwerks, having had a fair bit of experience with Love2d, and I'm having trouble with some standard Lua functions that I think should be working. In particular, I'm having trouble loading modules using the require function. I see people using the require function in examples, but when I try it I get "attempt to call global 'require' (a nil value)". It's as though the Lua standard libraries aren't loaded. Is there something I'm missing? Thank you, ye more-experienced-than-me, for any help. Quote Link to comment Share on other sites More sharing options...
Rick Posted August 26, 2014 Share Posted August 26, 2014 In LE use: import "path/path/file.lua" If I recall the LE environment isn't 100% exactly the same as the default Lua environment and require I think is one of those changes. 1 Quote Link to comment Share on other sites More sharing options...
NewPalette Posted August 26, 2014 Author Share Posted August 26, 2014 I see... import seems to work essentially by dumping the included script in place into the file that is using it. In Lua, it is possible, for example, to require a binary module, i.e. one distributed as a DLL. I was hoping to dynamically load http://moonscript.org/ modules, but the main moonscript module is distributed as a DLL that has to be required. Is there no way to use a binary Lua module within LE? Thanks. Quote Link to comment Share on other sites More sharing options...
Einlander Posted August 26, 2014 Share Posted August 26, 2014 In this case you would want to use lua ffi. http://luajit.org/ext_ffi.html it allows you to directly load dlls and their C headers, but odds are you will have alot of work ahead of you. Quote Link to comment Share on other sites More sharing options...
NewPalette Posted August 26, 2014 Author Share Posted August 26, 2014 In this case you would want to use lua ffi. http://luajit.org/ext_ffi.html it allows you to directly load dlls and their C headers, but odds are you will have alot of work ahead of you. Eh, I'm afraid I haven't made my point clear. Moonscript is a lua-targeted programming language, that comes with a DLL which contains a Lua module that allows you to dynamically compile and load Moonscript classes. So, what I'm trying to do isn't really load win32 binaries naively, I'm trying to do something that can already be done in Lua without any additional fanciness, since the "require" function can in fact load modules that are contained within binaries in this fashion. It seems this is just a function that is omitted from LE's Lua implementation. Quote Link to comment Share on other sites More sharing options...
Rick Posted August 26, 2014 Share Posted August 26, 2014 If you are using the Steam version try to turn off the sandbox mode. If you don't know how to do that then search the forums here for sandbox mode. Maybe that'll help. 2 Quote Link to comment Share on other sites More sharing options...
NewPalette Posted August 26, 2014 Author Share Posted August 26, 2014 If you are using the Steam version try to turn off the sandbox mode. If you don't know how to do that then search the forums here for sandbox mode. Maybe that'll help. YES YES! That's done it. Thank you so much. Quote Link to comment Share on other sites More sharing options...
Olby Posted October 13, 2014 Share Posted October 13, 2014 If you are using the Steam version try to turn off the sandbox mode. If you don't know how to do that then search the forums here for sandbox mode. Maybe that'll help. Just a quick note. Sandbox is on by default in standalone builds as well. Go to Tools -> Options -> Sandbox Lua and remove the check mark. 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...
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.