Chat about current Lua tools and IDEs

User avatar
By Highli
#52901 Hi there,

I try to create a simple library but it did'nt work with more than 1 function.

Here is the code of the lib:

Code: Select alllocal demo_mod = {}

function demo_mod.Mult(a, b)
  return a * b
end

function demo_mod.Add(a, b)
  return a + b
end

return demo_mod


And here the testcode for using the lib:

Code: Select alldemo = require "testlib"
local result1 = demo.Mult(10, 2)
local result2 = demo.Add(10, 2)
print(result1)
print(result2)


The result of executing is:

testlibtest.lua:3: attempt to call field 'Add' (a nil value)
stack traceback:
testlibtest.lua:3: in main chunk
[C]: in function 'dofile'
stdin:1: in main chunk

If I test it with only the first function "Mult", everything's fine!

I have no idea, what the problem is.

Any suggestions?

Regards

Erik