Page 1 of 1

LuaPlayer::swap_players

Posted: Thu Sep 04, 2025 7:11 pm
by _CodeGreen
May end up doing this myself, but figured I'd put it here in case someone else does it before I do.
Currently the only way to do this is with the console command /swap-players which calls Player::swap_players, but it would be neat if mods could do the same as well.

Re: LuaPlayer::swap_players

Posted: Tue Sep 09, 2025 7:52 am
by Bilka
Thank you for adding LuaPlayer::swap_characters() for 2.0.67.

Re: LuaPlayer::swap_players

Posted: Tue Sep 09, 2025 8:07 am
by Pi-C
Bilka wrote: Tue Sep 09, 2025 7:52 am Thank you for adding LuaPlayer::swap_characters() for 2.0.67.
Oooops, looks like I'll have to rework a major part of miniMAXIme

Re: LuaPlayer::swap_players

Posted: Tue Sep 09, 2025 8:11 am
by Bilka
The characters need players attached (you pass the player to the method, not the character) so I don't think this will work for character switcher mods.

Re: LuaPlayer::swap_players

Posted: Tue Sep 09, 2025 3:39 pm
by Pi-C
Bilka wrote: Tue Sep 09, 2025 8:11 am The characters need players attached …
Two players, two characters? Yes, that really wouldn't help my mod to exchange characters. However, it could be necessary (not sure, must check the code first) for my mod to update the character data (e.g. in games with modded characters, when the player's new character is based on a different prototype than the old one). Will you raise an event when characters are swapped?

Re: LuaPlayer::swap_players

Posted: Tue Sep 09, 2025 5:38 pm
by Bilka
It works exactly the same way as the existing console command mentioned in the first post.