Hey guys!
I found Tiled (
http://www.mapeditor.org/) quite a while ago (I was using Unity) and found it really useful.
I want to be able to load "tiled.lua" files into my C++ program.
I am using LuaBridge(
https://github.com/vinniefalco/LuaBridge) to do most of the heavy lifting.
But now I am stuck.
Let me show you how a Tiled map looks in lua:
bigtable
{
version = "2.2.2.2.2"
luaversion = "0.0.0.0.1"
tilesets
{
name = "Rock"
...
name = "Grass"
}
layers
{
data{0,0,0,0,0,0,0,0,0,1,2,3,4}
...
}
}
So yeah it is a lot of information in a table.
Using LuaBridge you can use: getGlobal(luaState,"key") to get a handler to that key value and then cast it into the apropiate type.
But,how do I "get" things without using a name(a char*) just using an id for example like:
lua_State* L = luaL_newstate();
luaL_dofile(L, "../data/scripts/untitled.lua");
luaL_openlibs(L);
lua_pcall(L, 0, 0, 0);
LuaRef globalData = getGlobal(L, "globalData");
LuaRef someKey = getGlobal(L,2);//How to do this
I am not sure how it should be done :C
Sorry it the answer is really obvious but I can´t find it :C