0
votes

I am new to Lua. I have ported Lua 5.2 to another platform. I am able to run Lua scripts. But have a problem with loading modules.
I have a sample.lua script below. In this script I am trying to call a function available in another Lua script using the require function. The require function fails at lua_load() with LUA_ERRSYNTAX. Not sure if this is problem with Lua 5.2 version.

sample.lua

require"module"

welcome()

module.lua

function welcome()
    print(" Hello in module")
end

The require function in sample.lua file locates the module.lua file but fails at lua_load(). Can anyone help me with this issue ?

1
lua_load pushes an error message on the stack in case of failures. Are you able to retrieve that message? - ComicSansMS
What do you mean by ported? Lua should compile unmodified in all platforms that have an ANSI C compiler. - lhf
lhf - I might be wrong here in when i mean ported. I ment i have lua5.2 working a device which runs on different OS - user2504302
ComicSansMS- It provides me module.lua:1: unexpected symbol near char(195). I really dont understand the meaning of this - user2504302

1 Answers

0
votes

Could You be more specific about those different OS'es? Firstly, You should compile Lua for exactly the same OS and device Your are running *.lua scripts on. Secondly, You should check module.lua for some weird typos and invisible symbols. String.char(195) doesn't seem very visible. Also, could You check the enconding of that/those two Lua scripts?