[0.16.22] Inconsistent fields for events

Bugs that are actually features.
Post Reply
fbo
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Dec 30, 2017 4:48 pm

[0.16.22] Inconsistent fields for events

Post by fbo »

Hello, on_player_placed_equipment contains equipment as LuaEquipment, but in on_player_removed_equipment the same field is only a string with the name.
As the latter could be easily written as event.equipment.name I believe it's a bug.
Last edited by fbo on Sun Feb 11, 2018 7:31 pm, edited 3 times in total.

User avatar
impetus maximus
Smart Inserter
Smart Inserter
Posts: 1299
Joined: Sat Aug 20, 2016 10:07 pm
Contact:

Re: Inconsistent fields for events

Post by impetus maximus »


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

Re: [0.16.22] Inconsistent fields for events

Post by Rseding91 »

Once the equipment is removed it doesn't exist anymore to get the name from so it's impossible to give a LuaEquipment in the event that doesn't exist.
If you want to get ahold of me I'm almost always on Discord.

fbo
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Dec 30, 2017 4:48 pm

Re: [0.16.22] Inconsistent fields for events

Post by fbo »

Oh, LuaEquipment is only for things in a grid. My misunderstanding was it would apply to anything that could be placed inside an armor.

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

Re: [0.16.22] Inconsistent fields for events

Post by Rseding91 »

fbo wrote:Oh, LuaEquipment is only for things in a grid. My misunderstanding was it would apply to anything that could be placed inside an armor.
I'm not understanding. The only things you can place in armor is equipment?
If you want to get ahold of me I'm almost always on Discord.

fbo
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Dec 30, 2017 4:48 pm

Re: [0.16.22] Inconsistent fields for events

Post by fbo »

The thing is: It's not equipment if outside a grid. The API doc for LuaEquipment clearly states:
Note: An equipment reference becomes invalid once the equipment is removed or the equipment grid (see LuaEquipmentGrid) it resides in is destroyed.
Same concept like entities, duh. Just a case of RTFM :roll:

Further browsing the excellent docs I came up with this to get the type of removed equipment:

Code: Select all

player.cursor_stack.prototype.place_as_equipment_result.type

Post Reply

Return to “Not a bug”