• Advertisement
Sign in to follow this  

Lua: Compilation with lua_load fails?

This topic is 4289 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement