1
In the main file.lua:
local calculadora = {
somar = function(x, y)
return x + y
end
}
function calculadora.multiplicar(x, y)
return x * y
end
return calculadora
In the Copyofmain file.
local calculadora = require("calculadora")
print(calculadora.somar(1, 1))
error:
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)
I put the script on Repl.it. There is also giving error
I tested here and to get it to work I renamed the file
CopyOfmain.lua
forcalculadora.lua
– Codigo de Senior
@Code for me keeps giving error, I put the script on the site repl it. and beyond the error
– GustavoGLD
@Jeffersonquesado Now I get it. I tested now and it worked! Thank you
– GustavoGLD
I put as response the comment, @Gustavogld
– Jefferson Quesado