Skip to content

JlnWntr/Lua-Adapter

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

Lua-Adapter

Use this C++-class to bind Lua 5.3+ or even MoonScript to C++.

Usage

#include "LuaAdapter.hpp"

int main(){
  LuaAdapter lua{"test.lua"};

  int width {0};
  lua.Get("width", width);  // width=600

  return 0;
}

Build and test Lua-Adapter using g++

$ g++-8 the_program_above.cpp -std=c++17 -llua -ldl

Please see more examples.

Build Lua 5.4.2 and test Lua-Adapter using CMake

The CMakeLists.txt in this directory downloads Lua, builds it and test-runs test.cpp.

$ cmake ./
$ make

It should be possible to build a (test-)project from here with Jetbrains CLion. (If the very first attempt to build fails, try Build > Rebuild 'test_lua' from the menu.)

Support for older g++-versions

If the latest g++ features are not available on your system (for example on Windows), then try Lua-Adapter/MiniLua. This is a somewhat minimal and simple version of Lua-Adapter which does not make use of new features (like if constexpr etc.)