Add support for getSelectedEntities functionality

This commit allows the script to be run on the entity(ies) selected at
runtime. If there are no entities selected, the user is prompted for a
selection.