From 60f45d55efa9bfbcab26c4ba873925e6a97d8a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sat, 24 Feb 2024 11:51:13 +0100 Subject: [PATCH 1/2] =?UTF-8?q?!OSDN:47829:S=C5=82awomir=20Lach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement city's counter value getter for lua scripts. Requires: #47827 . diff --git a/common/scriptcore/api_game_methods.c b/common/scriptcore/api_game_methods.c index d31cd16c77..4961b77206 100644 --- a/common/scriptcore/api_game_methods.c +++ b/common/scriptcore/api_game_methods.c @@ -310,6 +310,15 @@ const char *api_methods_counter_name_translation(lua_State *L, Counter *c) return counter_name_translation(c); } +/**********************************************************************//** + Obtain city's counter value +**************************************************************************/ +int api_methods_counter_city_get(lua_State *L, Counter *c, City *city) +{ + LUASCRIPT_CHECK_ARG_NIL(L, city, 3, City, -1); + + return city->counter_values[counter_index(c)]; +} /**********************************************************************//** Return TRUE iff city happy diff --git a/common/scriptcore/api_game_methods.h b/common/scriptcore/api_game_methods.h index a5d133cc89..af7e2315b3 100644 --- a/common/scriptcore/api_game_methods.h +++ b/common/scriptcore/api_game_methods.h @@ -66,6 +66,7 @@ bool api_methods_is_primary_capital(lua_State *L, City *pcity); /* Counter */ const char *api_methods_counter_rule_name(lua_State *L, Counter *c); const char *api_methods_counter_name_translation(lua_State *L, Counter *c); +int api_methods_counter_city_get(lua_State *L, Counter *c, City *city); /* Government */ const char *api_methods_government_rule_name(lua_State *L, diff --git a/common/scriptcore/tolua_game.pkg b/common/scriptcore/tolua_game.pkg index 3e40bc3b59..70ad60faa9 100644 --- a/common/scriptcore/tolua_game.pkg +++ b/common/scriptcore/tolua_game.pkg @@ -171,6 +171,7 @@ module game { module Counter { const char *api_methods_counter_rule_name @ rule_name (lua_State *L, Counter *c); const char *api_methods_counter_name_translation @ name_translation (lua_State *L, Counter *c); + int api_methods_counter_city_get @ get (lua_State *L, Counter *c, City *city); } /* Module Player. */ -- 2.43.2