After I added a check for not e.source or not e.source.valid
in that line, I got another crash, the API function surface.spill_item_stack()
does now take only one parameter, you have to do a few things to get it working:
e.surface.spill_item_stack({position=e.srcPos, stack={name=e.itemname, count=count}, allow_belts=false})
I have added the optional parameter allow_belts
so items won't be dropped on active belts which then transport the dropped item away.
EDIT: No, then no bot is being collected. :-( I need an other fix here.