Consistency issues in events on_placed/removed_equipment
-
LiroxDeYamon
- Burner Inserter

- Posts: 5
- Joined: Wed Apr 30, 2025 11:04 am
- Contact:
Consistency issues in events on_placed/removed_equipment
Hello!
Its really hard to do things with equipment as their events are inconsistent in naming, behavior and provided data.
Below is what i noticed so far an how I suggest fixing it.
Naming:
on_equipment_inserted and on_player_placed_equipment have different names ("inserted" != "placed"),
while on_equipment_removed and on_player_removed_equipment are consistent enough.
1. Doesn't really needs fixing, but it'll be nice to have consistent naming,
Behaviour:
equipment_inserted events are called per-item,
while equipment_removed events are called once.
2. I suggest changing equipment_removed events to be called per equipment removed.
Provided data:
equipment_inserted events provide equipment as LuaEquipment
but inside equipment_removed events its apparently just a string (I understand that it also has count, but its inconvenient).
All the equipment events lack ItemStack that was used/produced;
My suggestions are:
3. Include ItemStack that was used/produced
4. With suggestion 2 - provide equipment as LuaEquipment OR without suggestion 2 - provide table with all removed equipment
I wonder if any of this even possible to implement, but thanks in advance!
Its really hard to do things with equipment as their events are inconsistent in naming, behavior and provided data.
Below is what i noticed so far an how I suggest fixing it.
Naming:
on_equipment_inserted and on_player_placed_equipment have different names ("inserted" != "placed"),
while on_equipment_removed and on_player_removed_equipment are consistent enough.
1. Doesn't really needs fixing, but it'll be nice to have consistent naming,
Behaviour:
equipment_inserted events are called per-item,
while equipment_removed events are called once.
2. I suggest changing equipment_removed events to be called per equipment removed.
Provided data:
equipment_inserted events provide equipment as LuaEquipment
but inside equipment_removed events its apparently just a string (I understand that it also has count, but its inconvenient).
All the equipment events lack ItemStack that was used/produced;
My suggestions are:
3. Include ItemStack that was used/produced
4. With suggestion 2 - provide equipment as LuaEquipment OR without suggestion 2 - provide table with all removed equipment
I wonder if any of this even possible to implement, but thanks in advance!
Re: Consistency issues in events on_placed/removed_equipment
Unfortunately #1 #3 is just not currently viable due to how many places and ways the event can be sent (the current count is 15 places across robots, mods, direct player actions, copy-pasting spidertron settings and so on). #2 #4 is not possible because by the time the equipment is removed - it is gone - deleted - no longer exists. So, there is no equipment to provide in any event.
If you want to get ahold of me I'm almost always on Discord.
-
LiroxDeYamon
- Burner Inserter

- Posts: 5
- Joined: Wed Apr 30, 2025 11:04 am
- Contact:
Re: Consistency issues in events on_placed/removed_equipment
Interesting, what about ItemStack (#3)?
Re: Consistency issues in events on_placed/removed_equipment
Sorry, I meant #3 and #4. I updated the post.
If you want to get ahold of me I'm almost always on Discord.
- BraveCaperCat
- Filter Inserter

- Posts: 491
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: Consistency issues in events on_placed/removed_equipment
#1 can be done very easily...Rseding91 wrote: Mon Apr 27, 2026 1:10 pm Unfortunately #1 is just not currently viable due to how many places and ways can send the event (the current count is 15 places across robots, mods, direct player actions, copy-pasting spidertron settings and so on). #2 is not possible because by the time the equipment is removed - it is gone - deleted - no longer exists. So, there is no equipment to provide in any event.
Just find all instances of "on_player_placed_equipment" and replace them all with "on_player_inserted_equipment". (or "on_equipment_inserted" and "on_equipment_placed")
No? When an equipment is removed, it's placed in the inventory of the player/robot/whatever that removed it, unless it was deleted by a script. (in which case, it wouldn't be removed by a player) Even if it then turns into a LuaItem, we should at least get that LuaItem. Also, #2 refers to making the `equipment_removed` events be called for each equipment removed and not about providing the equipment. (that's #4)
-
LiroxDeYamon
- Burner Inserter

- Posts: 5
- Joined: Wed Apr 30, 2025 11:04 am
- Contact:
Re: Consistency issues in events on_placed/removed_equipment
#2 is kinda useless without #4BraveCaperCat wrote: Mon Apr 27, 2026 1:26 pm#1 can be done very easily...Rseding91 wrote: Mon Apr 27, 2026 1:10 pm Unfortunately #3 is just not currently viable due to how many places and ways can send the event (the current count is 15 places across robots, mods, direct player actions, copy-pasting spidertron settings and so on). #4 is not possible because by the time the equipment is removed - it is gone - deleted - no longer exists. So, there is no equipment to provide in any event.
Just find all instances of "on_player_placed_equipment" and replace them all with "on_player_inserted_equipment". (or "on_equipment_inserted" and "on_equipment_placed")
No? When an equipment is removed, it's placed in the inventory of the player/robot/whatever that removed it, unless it was deleted by a script. (in which case, it wouldn't be removed by a player) Even if it then turns into a LuaItem, we should at least get that LuaItem. Also, #2 refers to making the `equipment_removed` events be called for each equipment removed and not about providing the equipment. (that's #4)
Btw, how does the event provide equipment name and quality if the instance is already gone?
Re: Consistency issues in events on_placed/removed_equipment
Recording the ID (name and quality) before removing the equipment is simple. In Lua terms its as simple as:LiroxDeYamon wrote: Mon Apr 27, 2026 1:36 pm #2 is kinda useless without #4
Btw, how does the event provide equipment name and quality if the instance is already gone?
Code: Select all
local name = equipment.name
local quality = equipment.quality.name
grid.take(equipment)
send_equipment_removed(name, quality, 1)If you want to get ahold of me I'm almost always on Discord.
-
LiroxDeYamon
- Burner Inserter

- Posts: 5
- Joined: Wed Apr 30, 2025 11:04 am
- Contact:
Re: Consistency issues in events on_placed/removed_equipment
So equipment is accessible before the event, thats interesting.Rseding91 wrote: Mon Apr 27, 2026 1:55 pmRecording the ID (name and quality) before removing the equipment is simple. In Lua terms its as simple as:LiroxDeYamon wrote: Mon Apr 27, 2026 1:36 pm #2 is kinda useless without #4
Btw, how does the event provide equipment name and quality if the instance is already gone?
Code: Select all
local name = equipment.name local quality = equipment.quality.name grid.take(equipment) send_equipment_removed(name, quality, 1)
What if you just save all of the data as LuaEquipment but readonly? Like, not the link to the object, but deepcopy?
This could solve #4 if paired with #2.
What about ItemStack? does grid.take(equipment) output ItemStack?
Re: Consistency issues in events on_placed/removed_equipment
This is asking for a complete re-write of how LuaObjects work on the engine side and is not something I have any interest in attempting.LiroxDeYamon wrote: Mon Apr 27, 2026 2:04 pm So equipment is accessible before the event, thats interesting.
What if you just save all of the data as LuaEquipment but readonly? Like, not the link to the object, but deepcopy?
This could solve #4 if paired with #2.
It does not and that goes back to what I first mentioned: the number of ways and number of places that both put and take equipment are spread across too many places to be worth attempting something like this. The logic that does the evening is separate from the logic that does the actual changes to the equipment grid so there's no way for the event logic to know which stack(s) any equipment came from (if any) or which stack(s) the equipment went to (if any).LiroxDeYamon wrote: Mon Apr 27, 2026 2:04 pm What about ItemStack? does grid.take(equipment) output ItemStack?
If you want to get ahold of me I'm almost always on Discord.
-
LiroxDeYamon
- Burner Inserter

- Posts: 5
- Joined: Wed Apr 30, 2025 11:04 am
- Contact:
Re: Consistency issues in events on_placed/removed_equipment
Ok then what about extra data table containing equipment's shield, max_shield, energy, max_energy, etc?Rseding91 wrote: Mon Apr 27, 2026 2:35 pm This is asking for a complete re-write of how LuaObjects work on the engine side and is not something I have any interest in attempting.
You already provide some data like name and quality, so that prob shouldn't be that hard to implement.
