diff --git a/src/luascript.cpp b/src/luascript.cpp
index 24cde70..d6d042a 100644
--- a/src/luascript.cpp
+++ b/src/luascript.cpp
@@ -2187,6 +2187,7 @@ void LuaScriptInterface::registerFunctions()
registerMethod("Player", "getSlotItem", LuaScriptInterface::luaPlayerGetSlotItem);
+ registerMethod("Player", "createParty", LuaScriptInterface::luaPlayerCreateParty);
registerMethod("Player", "getParty", LuaScriptInterface::luaPlayerGetParty);
registerMethod("Player", "addOutfit", LuaScriptInterface::luaPlayerAddOutfit);
@@ -7474,6 +7475,7 @@ int LuaScriptInterface::luaPlayerCreate(lua_State* L)
return 1;
}
+
int LuaScriptInterface::luaPlayerIsPlayer(lua_State* L)
{
// player:isPlayer()
@@ -8721,6 +8723,32 @@ int LuaScriptInterface::luaPlayerGetSlotItem(lua_State* L)
return 1;
}
+int LuaScriptInterface::luaPlayerCreateParty(lua_State* L)
+{
+ // player:createParty(targetPlayer[, joinTargetPlayer = false])
+ Player* player = getUserdata<Player>(L, 1);
+ Player* targetPlayer = getUserdata<Player>(L, 2);
+ if (!player || !targetPlayer) {
+ lua_pushnil(L);
+ return 1;
+ }
+
+ Party* partyPlayer = player->getParty();
+ Party* partyInvitedPlayer = targetPlayer->getParty();
+
+ if (!partyPlayer && !partyInvitedPlayer) {
+ partyPlayer = new Party(player);
+ partyPlayer->invitePlayer(*targetPlayer);
+ bool joinTargetPlayer = getBoolean(L, 3, false);
+ if (joinTargetPlayer) {
+ partyPlayer->joinParty(*targetPlayer);
+ }
+ pushUserdata<Party>(L, partyPlayer);
+ setMetatable(L, -1, "Party");
+ }
+ return 1;
+}
+
int LuaScriptInterface::luaPlayerGetParty(lua_State* L)
{
// player:getParty()
diff --git a/src/luascript.h b/src/luascript.h
index 3f50e63..543de7f 100644
--- a/src/luascript.h
+++ b/src/luascript.h
@@ -928,6 +928,7 @@ class LuaScriptInterface
static int luaPlayerGetSlotItem(lua_State* L);
+ static int luaPlayerCreateParty(lua_State* L);
static int luaPlayerGetParty(lua_State* L);
static int luaPlayerAddOutfit(lua_State* L);