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.
on_player_placed_equipment by mod/player
- ickputzdirwech
- Filter Inserter
- Posts: 794
- Joined: Sun May 07, 2017 10:16 am
- Contact:
Re: on_player_placed_equipment by mod/player
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
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
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: on_player_placed_equipment by mod/player
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: on_player_placed_equipment by mod/player
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.
Re: on_player_placed_equipment by mod/player
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.
Do note that an inserter can... insert equipment into a grid under the correct conditions.
Re: on_player_placed_equipment by mod/player
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.
-
- Filter Inserter
- Posts: 359
- Joined: Thu Jun 01, 2017 12:05 pm
- Contact:
Re: on_player_placed_equipment by mod/player
Uuuh, how?mrudat wrote: Mon Nov 15, 2021 11:09 am Do note that an inserter can... insert equipment into a grid under the correct conditions.

Re: on_player_placed_equipment by mod/player
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.
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.
