Jump to content

require


NewPalette
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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.

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...