clothing = {}
clothing.temp_hair = {}

dofile(minetest.get_modpath('clothing')..'/hairstyles.lua')
dofile(minetest.get_modpath('clothing')..'/hats.lua')
dofile(minetest.get_modpath('clothing')..'/mannequin.lua')
dofile(minetest.get_modpath('clothing')..'/pants.lua')
dofile(minetest.get_modpath('clothing')..'/shirts.lua')
dofile(minetest.get_modpath('clothing')..'/shoes.lua')
dofile(minetest.get_modpath('clothing')..'/shop.lua')
dofile(minetest.get_modpath('clothing')..'/underclothes.lua')

minetest.create_detached_inventory('clothing_list', {
   allow_put = function(inv, listname, index, stack, player2)
      return 0
   end,
   allow_take = function(inv, listname, index, stack, player2)
      local name = player2 and player2:get_player_name() or ''
      if not creative.is_enabled_for(name) then
         return 0
      end
      return -1
   end,
   on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
   end,
})

local clothes = {}
minetest.register_on_mods_loaded(function()
   for name, def in pairs(minetest.registered_items) do
      local group = def.groups or {}
      if group.clothing then
         clothes[name] = def
      end
   end
   local list = {}
   for name, def in pairs(clothes) do
      list[#list+1] = name
   end
   local clothing_inv = minetest.get_inventory({type = 'detached', name = 'clothing_list'})
   clothing_inv:set_size('main', #list)
   clothing_inv:set_list('main', list)
   clothing.inv_size = #list
end)
