function Lv(a)
local lv = GetChaAttr( a , ATTR_LV )
return lv
end
function Lp(a)
local lp = GetChaAttr( a , ATTR_LP )
return lp
end
function Lv(a)
local lv = GetChaAttr( a , ATTR_LV )
return lv
end
function Lp(a)
local lp = GetChaAttr( a , ATTR_LP )
return lp
end
getGlobalNamespace(L)
.addFunction("GetChaAttr", &GetChaAttr);
.endNamespace();
where "L" is your lua state object. The parameters and return type of the function are automatically determined. The code for LuaBind would look similar.
LuaBridge looks good. Thank you. Im going to try it out.
I got a question..
If I want to run lua functions parallel do I have to load the files + functions every time a new user connects to the game?
Some shameless advertising :P
I wrote a tutorial with my limited knowledge. Maybe it will help you http://zwodahs.github.io/tutorial/lua/. If you don't want to read the tutorial, you can just check out my code from https://github.com/ZwodahS/lua-examples.
Let me know if there are anything missing =).
I looked at a few of the wrappers and didn't like them. Writing your own wrapper isn't that hard and you get full control over them. =)
Check out my blog at zwodahs.github.io and zwodahs.itch.io/
If I want to run lua functions parallel do I have to load the files + functions every time a new user connects to the game?
There are a couple different approaches for dealing with this. One way is to do as you say and create a new lua state with lua_open for each thread and reload your lua files for each new state. Using this method, however, global lua data cannot be shared between lua states. So if you need to access any global data, it will need to be exposed through a C++ function, which you can protect with a lock if necessary (if it's read only, you won't need any locks).
Another method is described here. This uses lua_newthread instead of lua_open to create a child state that can access global data. However this may have some performance issues as it could be locking more than you need.
Or you may want to try one of the lua threading libraries listed here like LuaLanes.