1

i have wrote the next lua module:

    --mod.lua
    local M = {}        
    function M.bar()
    print "bar"
    end
    return M

And i'm trying to use it on another lua script as:

    --main.lua
    function Main(context)
    local mod = require 'mod'
    mod.bar()
    end

But i am getting the error : "attempt to index ? (a boolean value)" on the line "mod.bar()" The same result is obtained if i use module(..., package.seeall) on the header of mod.lua. Could anybody help me?

3
  • 1
    It seems that your module has returned nil instead of a table. A typo in the module? Apr 16, 2013 at 20:26
  • Are you sure that you pasted the functions correctly? The program works fine on my end.
    – hjpotter92
    Apr 16, 2013 at 20:35
  • The only thing that comes till my mind is that require doesn't load appropriate file...
    – W.B.
    Apr 17, 2013 at 9:35

1 Answer 1

0

Thanks to W.B. my 'mod.lua' was in another path. Sorry for wasting your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.