CvLuaGame::lGetNumResourceRequiredForUnit(lua_State *)
- Defined in
- Lua/CvLuaGame.cpp, line 1931
- Class
- CvLuaGame
- Hook name
CivHooks::CvLuaGame_lGetNumResourceRequiredForUnit
Hooks
static bool BeforeCvLuaGame_lGetNumResourceRequiredForUnit(lua_State* L, int& result);static void AfterCvLuaGame_lGetNumResourceRequiredForUnit(lua_State* L, int& result);static int ReplaceCvLuaGame_lGetNumResourceRequiredForUnit(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaGame_lGetNumResourceRequiredForUnit>(host, &BeforeCvLuaGame_lGetNumResourceRequiredForUnit);CivRegisterAfter<CivHooks::CvLuaGame_lGetNumResourceRequiredForUnit>(host, &AfterCvLuaGame_lGetNumResourceRequiredForUnit);CivRegisterReplace<CivHooks::CvLuaGame_lGetNumResourceRequiredForUnit>(host, &ReplaceCvLuaGame_lGetNumResourceRequiredForUnit);
Code
1931int CvLuaGame::lGetNumResourceRequiredForUnit(lua_State* L)1932{1933 const UnitTypes eUnit = (UnitTypes) lua_tointeger(L, 1);1934 const ResourceTypes eResource = (ResourceTypes) lua_tointeger(L, 2);19351936 CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit);1937 if(pkUnitInfo == NULL)1938 {1939 luaL_error(L, "Unit row at ID %d is empty.", eUnit);1940 return 0;1941 }19421943 const int iNumNeeded = pkUnitInfo->GetResourceQuantityRequirement(eResource);19441945 lua_pushinteger(L, iNumNeeded);19461947 return 1;1948}
Calls
- CvGlobals::getUnitInfo(UnitTypes)
- CvUnitEntry::GetResourceQuantityRequirement(int) const
lua_pushintegerlua_tointegerluaL_error