Skip to content

Commit

Permalink
New function [leaveChannel] (otland#4394)
Browse files Browse the repository at this point in the history
  • Loading branch information
moviebr authored Nov 4, 2024
1 parent 86b4fef commit 8e9f360
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,6 +2871,7 @@ void LuaScriptInterface::registerFunctions()
registerMethod(L, "Player", "sendPrivateMessage", LuaScriptInterface::luaPlayerSendPrivateMessage);
registerMethod(L, "Player", "channelSay", LuaScriptInterface::luaPlayerChannelSay);
registerMethod(L, "Player", "openChannel", LuaScriptInterface::luaPlayerOpenChannel);
registerMethod(L, "Player", "leaveChannel", LuaScriptInterface::luaPlayerLeaveChannel);

registerMethod(L, "Player", "getSlotItem", LuaScriptInterface::luaPlayerGetSlotItem);

Expand Down Expand Up @@ -10427,6 +10428,20 @@ int LuaScriptInterface::luaPlayerOpenChannel(lua_State* L)
return 1;
}

int LuaScriptInterface::luaPlayerLeaveChannel(lua_State* L)
{
// player:leaveChannel(channelId)
uint16_t channelId = tfs::lua::getNumber<uint16_t>(L, 2);
Player* player = tfs::lua::getUserdata<Player>(L, 1);
if (player) {
g_game.playerCloseChannel(player->getID(), channelId);
tfs::lua::pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}

int LuaScriptInterface::luaPlayerGetSlotItem(lua_State* L)
{
// player:getSlotItem(slot)
Expand Down
1 change: 1 addition & 0 deletions src/luascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ class LuaScriptInterface

static int luaPlayerChannelSay(lua_State* L);
static int luaPlayerOpenChannel(lua_State* L);
static int luaPlayerLeaveChannel(lua_State* L);

static int luaPlayerGetSlotItem(lua_State* L);

Expand Down

0 comments on commit 8e9f360

Please sign in to comment.