#define scr_pickupItem /* Pickup items on collision with player. * Using a script run at the end of every step is less efficient than using * collision event but avoids the player sticking on items when * inventory is full. */ { var item_id; // Determine if collision with any item item_id = collision_rectangle(obj_playerController.x - 16, obj_playerController.y - 16, obj_playerController.x + 16, obj_playerController.y + 16, obj_item, false, true); if(item_id >= 1) { // Was a collision so try to add to inventory if(Inventory.full) exit; // Inventory full so just exit script sound_play(snd_pickup); with (item_id) { // Add only the object the player collided with to inventory Inventory_Add(); } } }