Add Lua API for fetching net income and related values

This commit is contained in:
Celtic Minstrel 2016-12-09 19:40:37 -05:00
parent c71b9306ed
commit ef1d052136
2 changed files with 14 additions and 0 deletions

View file

@ -3,6 +3,9 @@ Version 1.13.6+dev:
* Improved terrain graphics: lava.
* Language and i18n:
* Updated translations: British English, Portuguese (Brazil)
* Lua API:
* New attributes in side proxy:
num_units, num_villages, total_upkeep, expenses, net_income
* WML Engine:
* Removed LOW_MEM option when building.
* Add color= attribute to [floating_text]

View file

@ -16,6 +16,8 @@
#include "scripting/lua_common.hpp"
#include "team.hpp"
#include "resources.hpp" // for gameboard
#include "game_board.hpp"
#include <string>
@ -91,6 +93,15 @@ static int impl_side_get(lua_State *L)
return 1;
}
// These are blocked together because they are all part of the team_data struct.
// Some of these values involve iterating over the units map to calculate them.
team_data d = resources::gameboard->calculate_team_data(t);
return_int_attrib("num_units", d.units);
return_int_attrib("total_upkeep", d.upkeep);
return_int_attrib("num_villages", d.villages);
return_int_attrib("expenses", d.expenses);
return_int_attrib("net_income", d.net_income);
return_cfg_attrib("__cfg", t.write(cfg));
if(luaW_getmetafield(L, 1, m)) {
return 1;