No arquivo main.lua:
local calculadora = {
somar = function(x, y)
return x + y
end
}
function calculadora.multiplicar(x, y)
return x * y
end
return calculadora
No arquivo CopyOfmain.lua
local calculadora = require("calculadora")
print(calculadora.somar(1, 1))
erro:
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: ..._64\workspace\criando bilbiotecas\src\CopyOfmain.lua:1: module 'calculadora' not found:
no field package.preload['calculadora']
no file '.\calculadora.lua'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\lua\calculadora.lua'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\lua\calculadora\init.lua'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\calculadora.lua'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\calculadora\init.lua'
no file 'C:\Users\lidio\Downloads\org.eclipse.ldt.product-win32.win32.x86_64\workspace\criando bilbiotecas\src\calculadora.lua'
no file 'C:\Users\lidio\Downloads\org.eclipse.ldt.product-win32.win32.x86_64\workspace\criando bilbiotecas\src\calculadora\init.lua'
no file 'C:\Users\lidio\Downloads\org.eclipse.ldt.product-win32.win32.x86_64\workspace\criando bilbiotecas\src\calculadora.luac'
no file 'C:\Users\lidio\Downloads\org.eclipse.ldt.product-win32.win32.x86_64\workspace\criando bilbiotecas\src\calculadora\init.luac'
no file '.\calculadora.dll'
no file '.\calculadora51.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\calculadora.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\calculadora51.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\clibs\calculadora.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\clibs\calculadora51.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\loadall.dll'
no file 'C:\Program Files\Java\jre1.8.0_251\bin\clibs\loadall.dll'
at com.naef.jnlua.LuaState.lua_pcall(Native Method)
at com.naef.jnlua.LuaState.call(LuaState.java:555)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:128)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:143)
Coloquei o script no repl.it (https://replRepl.it/@GustavoGLD/calculadora#calc.lua). Lá também está dando erro