I'm not 100% sure this is a bug or a feature, but I'm quite sure it was different in 1.0 and I could not find a changelog-entry on this.
Whilst messing around with my code and some chests I found that the event 'on_gui_opened' behaves differently if a requester/buffer chest contains requests or not.
Might be the same with other entities that provide request-slots.
If requests are configured, the entities player and inventory can be extracted.
If NO requests are configured these two entities are 'nil'.
'entity' seems to exist if anything other than the player-inventory is opened.
I'm quite but not absolutely sure this was different before 1.1.x
test-code:
Code: Select all
script.on_event(defines.events.on_gui_opened, function(event)
local player, inventory = get_event_entities(event) -- missing both entities if chest without configured requests
game.players[1].print ("on_gui_opened:")
if (player) then -- exists if player-inventory or chest with configured requests opened, otherwise nil
game.players[1].print ("player.name: '" .. serpent.line(player.name) .. "'")
end
if (inventory) then -- exists if player-inventory or chest with configured requests opened, otherwise nil
game.players[1].print ("inventory.name: '" .. serpent.line(inventory.name) .. "'")
end
if (event.entity) then -- nil if player-inventory opened, exists if another entity is opened
game.players[1].print ("event.entity.name: '" .. serpent.line(event.entity.name).. "'")
end
end)
'event.entity.request_slot_count' returns '0' regardless if I open a requester chest (without pre defined requests) or a storage-chest for example...
best regards,
Daeruun