When having an item that lays down a tile, the on_player_built_tile event fires. When ghosting a tile, the on_build_entity fires that created a tile-ghost. However, the only way to get the name of the actual item that layed down this tile-ghost (as in the item that lays down tiles) is by checking the event.stack. In the case the player doesn't have items, so he just used the filter on his hotbar to lay down ghosts, the stack is obviously not valid to read and there is no way of reconstructing the actual item that was used.
I found this while working on my Land Mover mod, the function in question is on github for this report. So when the event fires but the event.stack is not valid_for_read, I have no way of getting the exact item prototype name of the item used to create that ghost.
EDIT: This code example shows the actual time the item name cannot be extracted (where it prints invalid stack)
Code: Select all
on_ghost_tile = function(event)
if event.created_entity.name == "tile-ghost" then
if event.stack and event.stack.valid_for_read then
if event.stack.name == "landmover" or event.stack.name == "landmover-mk2" then
game.players[event.player_index].print{"messages.LM-no-tile-ghost"}
event.created_entity.destroy()
end
else
game.players[event.player_index].print("invalid stack")
end
end
end,
lovely_santa