Sign in to follow this  
Toolmaker

Lua: Compilation with lua_load fails?

Recommended Posts

Toolmaker    967
I'm currently working on some sample code to get Lua working from within Java(It's for a school project, where we have to tutor out class on a subject, we have choose JNI). Anyway, I got it to load some code, HOWEVER, when I use this: if (l.DoString(vm, "global t = function (a)\n return (a * a);\n end\n") != 0) It goes nuts. When I look at my code, the function does look ok: global t = function(a) return a * a; end How come, that lua_load causes errors? This is the error: Error from load: [string "?"]:1: `=' expected near `t' What's wrong? And how do I fix it? Because I have no idea... Toolmaker

Share this post


Link to post
Share on other sites
Ximmer    314
There is no global keyword in lua. If you define someting ouside of a function it is considered global.

if (l.DoString(vm, "t = function (a)\n return (a * a);\n end\n") != 0)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this