Add Lua API for fetching net income and related values
This commit is contained in:
parent
c71b9306ed
commit
ef1d052136
2 changed files with 14 additions and 0 deletions
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue