lua
local function on_dispatcher_updated(event)
for train_id, delivery in pairs event.deliveries do
if not global.deliveries[train_id] then
-- new delivery
end
end
global.deliveries = event.deliveries
end
That's what I had in mind, thanks. Will try it during the weekend.
With one event per delivery you'd also have to subscribe to on_dispatcher_updated just to have something telling you when all deliveries are created.
The more I think about it the less sense an event for on_delivery_created makes.
Yes, I understand that this won't be a popular API function. I just didn't want to iterate through all the deliveries because I thought it would be slow, but that's probably just premature optimization.