本文整理汇总了C++中LuaTable::GetLua方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaTable::GetLua方法的具体用法?C++ LuaTable::GetLua怎么用?C++ LuaTable::GetLua使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaTable
的用法示例。
在下文中一共展示了LuaTable::GetLua方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _get_bay_ids
// Data format example:
// bay_groups = {
// {0, 500, {1}},
// },
static int _get_bay_ids(lua_State *L, const char *key, SpaceStationType::TBayGroups &outBayGroups, unsigned int &outNumDockingPorts)
{
LUA_DEBUG_START(L);
LuaTable t = LuaTable(L, -1).Sub(key);
if (t.GetLua() == 0) {
luaL_error(L, "The bay group isn't a proper table (%s)", key);
}
if (t.Size() < 1) {
return luaL_error(L, "Station must have at least 1 group of bays in %s", key);
}
LuaTable::VecIter<LuaTable> it_end = t.End<LuaTable>();
for (LuaTable::VecIter<LuaTable> it = t.Begin<LuaTable>(); it != it_end; ++it) {
SpaceStationType::SBayGroup newBay;
newBay.minShipSize = it->Get<int>(1);
newBay.maxShipSize = it->Get<int>(2);
LuaTable group = it->Sub(3);
if (group.GetLua() == 0) {
luaL_error(L, "A group is of the form {int, int, table} (%s)", key);
}
if (group.Size() == 0) {
return luaL_error(L, "Group must have at least 1 bay %s", key);
}
newBay.bayIDs.reserve(group.Size());
LuaTable::VecIter<int> jt_end = group.End<int>();
for (LuaTable::VecIter<int> jt = group.Begin<int>(); jt != jt_end; ++jt) {
if ((*jt) < 1) {
return luaL_error(L, "Valid bay ID ranges start from 1 %s", key);
}
newBay.bayIDs.push_back((*jt)-1);
++outNumDockingPorts;
}
lua_pop(L, 1); // Popping group
outBayGroups.push_back(newBay);
}
lua_pop(L, 1); // Popping t
LUA_DEBUG_END(L, 0);
return 0;
}
示例2: _get_stage_durations
static int _get_stage_durations(lua_State *L, const char *key, int &outNumStages, double **outDurationArray)
{
LUA_DEBUG_START(L);
LuaTable stages = LuaTable(L, -1).Sub(key);
if (stages.GetLua() == 0) {
luaL_error(L, "Not a proper table (%s)", key);
}
if (stages.Size() < 1)
return luaL_error(L, "Station must have at least 1 stage in %s", key);
outNumStages = stages.Size();
*outDurationArray = new double[stages.Size()];
std::copy(stages.Begin<double>(), stages.End<double>(), *outDurationArray);
lua_pop(L, 1); // Popping t
LUA_DEBUG_END(L, 0);
return 0;
}