Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <luabind/luabind.hpp>
  2. #include <luaconf.h>
  3. #include <iostream>
  4. #define LUA_COMPAT_AL
  5. int main() {
  6. // Create a new lua state
  7. lua_State *myLuaState = luaL_newstate();
  8.  
  9. // Connect LuaBind to this lua state
  10. luabind::open(myLuaState);
  11.  
  12. // Define a lua function that we can call
  13. luaL_dostring(
  14. myLuaState,
  15. "function add(first, second)\n"
  16. " return first + second\n"
  17. "end\n"
  18. );
  19. std::cout << "Result: "
  20. << luabind::call_function<int>(myLuaState, "add", 2, 3)
  21. << std::endl;
  22.  
  23. lua_close(myLuaState);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement