LuaPlayer.entity_copy_source is actually associated to the character, not the player

Bugs that are actually features.
User avatar
Wiwiweb
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Sat May 08, 2021 2:36 am
Contact:

LuaPlayer.entity_copy_source is actually associated to the character, not the player

Post by Wiwiweb »

Problem reproduction
I have this setup with 2 characters and a machine (save file is attached to this post):
Screenshot 2022-07-23 121100.png
Screenshot 2022-07-23 121100.png (74.82 KiB) Viewed 836 times
1) I am currently controlling the top character. I shift-right click the assembling machine.
2)

Code: Select all

/c game.print(game.player.entity_copy_source.name)
gives me "assembling-machine-3" as expected.
3) I swap characters using this:

Code: Select all

/c local char = game.surfaces.nauvis.find_entities_filtered{name = "character", force = "player", limit = 1, position={4,3}, radius=2}[1]
game.player.set_controller{type=defines.controllers.character, character=char}
4) I print game.player.entity_copy_source again, this time it's nil.
5) I swap back to the first character:

Code: Select all

/c local char = game.surfaces.nauvis.find_entities_filtered{name = "character", force = "player", limit = 1, position={4,0}, radius=2}[1]
game.player.set_controller{type=defines.controllers.character, character=char}
4) I print game.player.entity_copy_source again,it is back to "assembling-machine-3".
Expected
Given that this is a property of LuaPlayer, I would expect this value to stay the same even when the player switches character.
Why
This is currently an annoyance in the Jetpack mod. Every time you take off or land, you lose your copy settings.
Attachments
entity-copy-source-test.zip
(1.28 MiB) Downloaded 52 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 14055
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaPlayer.entity_copy_source is actually associated to the character, not the player

Post by Rseding91 »

Thanks for the report however this is working correctly. "LuaPlayer" is simply a wrapper around some combination of: the character entity, the player object, and the controller the player is currently using.

However unrelated, I checked master and it was actually moved to the player object so when that's released it will work as you're wanting.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Not a bug”