I did a first small test with LuaBridge 1 week ago and it worked to get an int from the script.
Now I deleted this code and tried to include Lua script in my game engine but it is no longer working. I tried to go back to a basic code with this :
#include <iostream>
#include "lua5.2/lua.hpp"
#include "LuaBridge/LuaBridge.h"
using namespace luabridge;
int main()
{
lua_State* L;
L = luaL_newstate();
if(!luaL_loadfile(L, "../../script.lua"))
std::cout << "failed loading" << std::endl;
LuaRef s = getGlobal(L, "nmbr");
int luaInt = s.cast<int>();
std::cout << luaInt << std::endl;
return 0;
}
with this script
nmbr = 30
And it gives me :
PANIC: unprotected error in cell to Lua API (bad argument #2 (number expected, got nil)) Aborted (core dumped)
It the same when I tried to get a string or a function from the script and I have no idea what I'm doing wrong in this.
Thanks for your answers :)