LuaPlayer::swap_players

User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sat Mar 05, 2022 11:30 am
Contact:

LuaPlayer::swap_players

Post 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.
My Mods | If you can't make it perfect, make it adjustable
Bilka
Factorio Staff
Factorio Staff
Posts: 3562
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::swap_players

Post by Bilka »

Thank you for adding LuaPlayer::swap_characters() for 2.0.67.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1769
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: LuaPlayer::swap_players

Post 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
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Bilka
Factorio Staff
Factorio Staff
Posts: 3562
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::swap_players

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1769
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: LuaPlayer::swap_players

Post 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?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Bilka
Factorio Staff
Factorio Staff
Posts: 3562
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::swap_players

Post by Bilka »

It works exactly the same way as the existing console command mentioned in the first post.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Implemented mod requests”