How to efficiently tell workers to return minerals before going to build something in Starcraft 2?
The "Return Cargo" command is what you're looking for here, (default C). This command when issued will tell the worker to return the resources they are carrying.
The way you would use this command is to first tell the worker to go to some place, in your situation it would be the place you want to construct something. You would then hit "Return Cargo", if the worker is not carrying resources then you can not issue this command, as the command will change to "Harvest Resources", if they are carrying resources they will return them to the base.
So after sending the "Return Cargo" command you would hold shift [1] and then queue the building that you'd like to build.
[1] Note: There's a chance that depending on the timing the worker will go mine resources first, that is why myself and many people I've seen do not queue this command, but rather spam C while sending the move command (this is due to the worker queueing up mining first and then go do your queued command) until they can see that none are carrying resources (from the lack of the "Return Cargo" command).
So to answer your question, the sequence would be:
- Camera Key for building location
- Control group with worker
- Click to move
- C "Return Cargo"
- Building keys
If you wanted to handle the third situation efficiently too, you would shift click to somewhere near the resources/base, then C then click to move to building location.