From 3bed0981d058b512bfb8aeeeeed235c9ee9385af Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 15 Aug 2020 15:45:28 +0200 Subject: UI Update; Added AutoTool --- src/script/lua_api/l_localplayer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/script/lua_api/l_localplayer.cpp') diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index bde120c1d..2644893f9 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common/c_content.h" #include "client/client.h" #include "client/content_cao.h" +#include "client/game.h" LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m) { @@ -86,6 +87,17 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L) return 1; } +// set_wield_index(self) +int LuaLocalPlayer::l_set_wield_index(lua_State *L) +{ + LocalPlayer *player = getobject(L, 1); + u32 index = luaL_checkinteger(L, 2); + + player->setWieldIndex(index); + g_game->processItemSelection(&g_game->runData.new_playeritem); + return 0; +} + // get_wielded_item(self) int LuaLocalPlayer::l_get_wielded_item(lua_State *L) { @@ -468,6 +480,7 @@ const luaL_Reg LuaLocalPlayer::methods[] = { luamethod(LuaLocalPlayer, get_hp), luamethod(LuaLocalPlayer, get_name), luamethod(LuaLocalPlayer, get_wield_index), + luamethod(LuaLocalPlayer, set_wield_index), luamethod(LuaLocalPlayer, get_wielded_item), luamethod(LuaLocalPlayer, is_attached), luamethod(LuaLocalPlayer, is_touching_ground), -- cgit v1.2.3