Bazaar developer reference

CvLuaUnit::lGetActivePath(lua_State *)

Defined in
Lua/CvLuaUnit.cpp, line 751
Class
CvLuaUnit
Not a hook point
member without a separate declaration

Code

751int CvLuaUnit::lGetActivePath(lua_State* L)752{753	CvUnit* pkUnit = GetInstance(L);754755	lua_createtable(L, 0, 0);756	int iCount = 1;757758	CvPlot* pDestPlot = pkUnit->LastMissionPlot();759	if (pDestPlot) {760		pkUnit->GeneratePath(pDestPlot);761762		const CvPathNodeArray& kPathNodeArray = pkUnit->GetPathNodeArray();763764		for (int i = ((int)kPathNodeArray.size())-1; i >=0 ; --i)765		{766			const CvPathNode& kNode = kPathNodeArray[i];767768			lua_createtable(L, 0, 0);769			const int t = lua_gettop(L);770			lua_pushinteger(L, kNode.m_iX);771			lua_setfield(L, t, "X");772			lua_pushinteger(L, kNode.m_iY);773			lua_setfield(L, t, "Y");774			lua_pushinteger(L, kNode.m_iData1);775			lua_setfield(L, t, "RemainingMovement");776			lua_pushinteger(L, kNode.m_iData2);777			lua_setfield(L, t, "Turn");778			lua_pushinteger(L, kNode.m_iFlags);779			lua_setfield(L, t, "Flags");780			lua_pushboolean(L, kNode.GetFlag(CvPathNode::PLOT_INVISIBLE));781			lua_setfield(L, t, "Invisible");782			lua_pushboolean(L, kNode.GetFlag(CvPathNode::PLOT_ADJACENT_INVISIBLE));783			lua_setfield(L, t, "AdjInvisible");784			lua_rawseti(L, -2, iCount++);785		}786	}787788	return 1;789}

Calls

Called by