Get the entity copied by shift-right-button ?

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Get the entity copied by shift-right-button ?

Post 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...
My mods on the Factorio Mod Portal :geek:
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

If you want to get ahold of me I'm almost always on Discord.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

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

Post 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.
My mods on the Factorio Mod Portal :geek:
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

I don't understand what you're asking for...
If you want to get ahold of me I'm almost always on Discord.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

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

Post 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.
My mods on the Factorio Mod Portal :geek:
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

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

Post 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.
My mods on the Factorio Mod Portal :geek:
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

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

Post 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.
quick links: log file | graphical issues | wiki
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

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

Post by binbinhfr »

Added LuaPlayer::entity_copy_source - the source entity used during entity settings copy paste.
Thx Rseding !
My mods on the Factorio Mod Portal :geek:
Post Reply

Return to “Modding discussion”