//attach to they keys you whant to use
action my_key()
{
set(my, PASSABLE);
while (!player) {wait (1);} // wait until the player is loaded
while (vec_dist (player.x, my.x) > 50) // this loop runs until the player picks up the key
{
my.pan += 5 * time_step; // 5 gives the rotation speed of the key
wait (1);
//
}
// the player has got the key here
got_key += 1; //add 1 key more
wait(1);
set(my, INVISIBLE);
}