# Lua: Compilation with lua_load fails?

## 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 on other sites
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)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628308
• Total Posts
2981979

• 9
• 9
• 13
• 11
• 12