Page 1 of 1

Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 10:19 am
by binbinhfr
Hi,

I wonder if there is a way to get the entity that is copied when you do a shift-right-button ?
Because I want to do my own paste from this source...

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 10:34 am
by Rseding91

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 10:46 am
by binbinhfr
I already tried this one,
but it only works when doing the paste operation with shift-left-click on a single destination.

I am writing a mod that is doing multiple paste at once on several destination objects.
So I defined a selection tool, that I want to use for the paste part, calling several times copy_settings.
But for the copy part, it would be nice if I retain the classical factorio copy that users already know : "shit-right-click".

So I just need to get the source part of the on_pre_entity_settings_pasted, before the classical paste is done.

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 12:08 pm
by Rseding91
I don't understand what you're asking for...

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 12:32 pm
by binbinhfr
Sorry for my english, I will rephrase :

When the user clicks on shift-right-mouse on an entity (the "copy" part of the classical copy-paste process), I would like to get the entity that was selected.
I.e. the entity that will appear as the source in the on_pre_entity_settings_pasted, ONLY IF the user makes a shift-left-click to paste.
So I would like to get this entity BEFORE the user makes any paste with shift-left-mouse.

Because I want to make my own multiple paste selection tool. So the on_pre_entity_settings_pasted will not be triggered by my custom selection tool taht I will use for multiple pasting.

EDIT : to be short, there is already a player.selected variable.
I'm looking for a player.copy_source variable. That contains the last entity that was shift-right-clicked.

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 3:05 pm
by binbinhfr
Rseding, here is the tool I wrote, so that you see what I try to say.
viewtopic.php?f=92&t=30163

look at image no2.
it's here that I would like to use the classical shift-right-mouse source object.

Re: Get the entity copied by shift-right-button ?

Posted: Sat Jul 30, 2016 9:20 pm
by daniel34
Looks like it was implemented in 0.13.13:
FactorioBot wrote:
  • Scripting
    • Added LuaPlayer::entity_copy_source - the source entity used during entity settings copy paste.
Factorio Lua API wrote:entity_copy_source :: LuaEntity [Read-only]
  • The source entity used during entity settings copy-paste if any.
    nil if there isn't currently a source entity.

Re: Get the entity copied by shift-right-button ?

Posted: Sun Jul 31, 2016 12:01 am
by binbinhfr
Added LuaPlayer::entity_copy_source - the source entity used during entity settings copy paste.
Thx Rseding !