state.cpp 410 B

12345678910111213141516171819202122232425262728
  1. #include <lua.hpp>
  2. #include <luwra.hpp>
  3. #include <string>
  4. #include <iostream>
  5. using namespace luwra;
  6. int main() {
  7. StateWrapper state;
  8. state.loadStandardLibrary();
  9. state["foo"] = 1337;
  10. int r = state.runString(
  11. "foo = foo + 1"
  12. );
  13. if (r != LUA_OK) {
  14. std::cerr << read<std::string>(state, -1) << std::endl;
  15. return 1;
  16. }
  17. int value = state["foo"];
  18. std::cout << value << std::endl;
  19. return 0;
  20. }