on_player_placed_equipment by mod/player

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

on_player_placed_equipment by mod/player

Post by Linver »

Hi, is possible add to the event on_player_placed_equipment a new argument like "raised_by_a_mod" or a sort of, that with a boolean value, will inform the callback if the event was raised from a mod using the function LuaEquipmentGrid.put(...) ?

As always, thank you for the attention.

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: on_player_placed_equipment by mod/player

Post by ickputzdirwech »

They added two new events on_equipment_inserted and on_equipment_removed. However you still can't isolate when equipment was inserted/removed by script, since the new events also fire when it was done by the player. In case there is a way to do it, I would be interested in that.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: on_player_placed_equipment by mod/player

Post by eradicator »

Afaik the player can only insert into grids they have an open gui of. So you should be able to isolate the cases that are definetly by script, leaving a mangled rest of player-or-script situations. (Based on basic logic without having had a look at the events.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

curiosity
Filter Inserter
Filter Inserter
Posts: 315
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: on_player_placed_equipment by mod/player

Post by curiosity »

A better and unambiguous logic would be to check if both events fire. If yes, then placed by a player (and you get which from the player event). The effectiveness of this depends on the event order though.

User avatar
mrudat
Fast Inserter
Fast Inserter
Posts: 222
Joined: Fri Feb 16, 2018 5:21 am
Contact:

Re: on_player_placed_equipment by mod/player

Post by mrudat »

Perhaps an optional player field in on_equipment_inserted, if nil, it wasn't a player?

Do note that an inserter can... insert equipment into a grid under the correct conditions.

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

Re: on_player_placed_equipment by mod/player

Post by Rseding91 »

Why does it matter if it was done by a player or not?
If you want to get ahold of me I'm almost always on Discord.

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 275
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: on_player_placed_equipment by mod/player

Post by DarkShadow44 »

mrudat wrote:
Mon Nov 15, 2021 11:09 am
Do note that an inserter can... insert equipment into a grid under the correct conditions.
Uuuh, how? :o

User avatar
mrudat
Fast Inserter
Fast Inserter
Posts: 222
Joined: Fri Feb 16, 2018 5:21 am
Contact:

Re: on_player_placed_equipment by mod/player

Post by mrudat »

Edit: To actually address the topic:

I suspect that one reason to want to know if the event was raised by a script is to avoid two scripts duelling over what precisely should be in the equipment grid or not.

I assume that that's a large part of why the script_raised events exist.

---

At least in 0.18, an item that is both a fuel item and equipment will be happily inserted by an inserter into a locomotive with an equipment grid's equipment grid.*

I don't know if it works in the general case of equipment that isn't also a fuel item, or if it still works that way in 1.1, but it was definitely a "Huh, that's weird" moment.

* This sentence was provided to you by the Department of Redundancy Department. :D

Post Reply

Return to “Modding interface requests”