From ec91b09e2fc8dfb32858b20c19275b8d32e9ae5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sat, 17 Feb 2024 18:26:24 +0100 Subject: [PATCH 1/2] =?UTF-8?q?!OSDN:47829:S=C5=82awomir=20Lach=20?= 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_counters.c b/common/scriptcore/api_game_counters.c index f9e52839ec..65ce6fa26c 100644 --- a/common/scriptcore/api_game_counters.c +++ b/common/scriptcore/api_game_counters.c @@ -44,3 +44,13 @@ const char *api_counter_name_translation(lua_State *L, Counter *c) return counter_name_translation(c); } + +/**********************************************************************//** + Obtain city's counter value +**************************************************************************/ +int api_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)]; +} diff --git a/common/scriptcore/api_game_counters.h b/common/scriptcore/api_game_counters.h index 8dceb5ca13..c74e46a795 100644 --- a/common/scriptcore/api_game_counters.h +++ b/common/scriptcore/api_game_counters.h @@ -21,4 +21,5 @@ struct lua_State; const char *api_counter_rule_name(lua_State *L, Counter *c); const char *api_counter_name_translation(lua_State *L, Counter *c); +int api_counter_city_get(lua_State *L, Counter *c, City *city); #endif diff --git a/common/scriptcore/tolua_game.pkg b/common/scriptcore/tolua_game.pkg index ad15049f9d..211c48afb5 100644 --- a/common/scriptcore/tolua_game.pkg +++ b/common/scriptcore/tolua_game.pkg @@ -172,6 +172,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_counter_city_get @ get (lua_State *L, Counter *c, City *city); } /* Module Player. */ -- 2.43.1