Makes easy getting data from a LUA file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
luawrapper.cc
luawrapper.h

README.md

LuaWrapper

Makes easy getting data from a LUA file

Highlights

  • Makes use of Lua

How to use

  • First you have to do is to create a LuaWrapper object and call his init() method setting the Lua file you want to get data from:
#include "LuaWrapper"

int main() {

  LuaWrapper lua;
  lua.init("../file.lua"); // <--- path of your file

  return 0;
}
  • Then you can get data from the file:
-- LUA FILE

integer = 50;

table1 = {
  integer = 25,
  number = 10.5
};

array = { 1, 2, 3, 4, 5 };

table2 = {
  array_of_integers = { 1, 2, 3, 4, 5 },
  array_of_numbers = { 1.0, 2.0, 3.0, 4.0, 5.0 }
};
// CPP FILE

int a = lua.getGlobalInteger("integer");

float b = lua.getIntegerFromTable("table1", "number");

std::vector<int> c = lua.getGlobalArrayOfIntegers("array");

std::vector<float> d = lua.getArrayOfNumbersFromTable("table2", "array_of_numbers");