How to do occupied slots? with variables ,etc

Hi, my use is case is that i am doing a loudout system for a rpg game, where i can equip accesories by just clicking a button, i have 5 avaible slots, how could i detect if any slot is avaible and not occupied so i can use that slot?, and sort it automatically? , how could i do this with variables ? (or tables)