Many of Maya's tools are used in an interactive manner, with the user specifying inputs as needed, and actions taking place either when the necessary number of inputs have been provided, or the user hits the Enter key.
So far, none of our scripts have worked this way—it has been necessary to have the user explicitly run the script, or press a button. That works fine for many things, but providing interactive input can add a lot of polish to a script. In this example, we'll be doing exactly that.
We'll create a script that, once invoked, prompts the user to select two or more objects. When they press the Enter key, we'll create a locator at the average position of all of the objects. To do that, we'll need to create a custom context to implement our very own tool.