From 066dd8cf7789fff841b0d41528d289cd3eb6502d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 27 Jan 2022 00:53:19 +0200 Subject: [PATCH 35/35] Lua: Implement find.player(name) See osdn #43705 Signed-off-by: Marko Lindqvist --- common/scriptcore/api_game_find.c | 10 ++++++++++ common/scriptcore/api_game_find.h | 1 + common/scriptcore/tolua_game.pkg | 2 ++ 3 files changed, 13 insertions(+) diff --git a/common/scriptcore/api_game_find.c b/common/scriptcore/api_game_find.c index 970440a868..b0ef7aa2ec 100644 --- a/common/scriptcore/api_game_find.c +++ b/common/scriptcore/api_game_find.c @@ -25,6 +25,16 @@ #include "api_game_find.h" +/**********************************************************************//** + Return a player with the given name +**************************************************************************/ +Player *api_find_player_by_name(lua_State *L, const char *name) +{ + LUASCRIPT_CHECK_STATE(L, NULL); + + return player_by_name(name); +} + /**********************************************************************//** Return a player with the given player_id. **************************************************************************/ diff --git a/common/scriptcore/api_game_find.h b/common/scriptcore/api_game_find.h index 312bd1ad06..8594adcde6 100644 --- a/common/scriptcore/api_game_find.h +++ b/common/scriptcore/api_game_find.h @@ -25,6 +25,7 @@ extern "C" { #include "luascript_types.h" /* Object find module. */ +Player *api_find_player_by_name(lua_State *L, const char *name); Player *api_find_player(lua_State *L, int player_id); City *api_find_city(lua_State *L, Player *pplayer, int city_id); diff --git a/common/scriptcore/tolua_game.pkg b/common/scriptcore/tolua_game.pkg index 216b47984d..37d9c7e2ea 100644 --- a/common/scriptcore/tolua_game.pkg +++ b/common/scriptcore/tolua_game.pkg @@ -475,6 +475,8 @@ module City_List_Link { /* Module find. */ module find { + Player *api_find_player_by_name + @ player (lua_State *L, const char *name); Player *api_find_player @ player (lua_State *L, int player_id); City *api_find_city -- 2.34.1