init.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. clothing = {}
  2. clothing.temp_hair = {}
  3. dofile(minetest.get_modpath('clothing')..'/hairstyles.lua')
  4. dofile(minetest.get_modpath('clothing')..'/hats.lua')
  5. dofile(minetest.get_modpath('clothing')..'/mannequin.lua')
  6. dofile(minetest.get_modpath('clothing')..'/pants.lua')
  7. dofile(minetest.get_modpath('clothing')..'/shirts.lua')
  8. dofile(minetest.get_modpath('clothing')..'/shoes.lua')
  9. dofile(minetest.get_modpath('clothing')..'/shop.lua')
  10. dofile(minetest.get_modpath('clothing')..'/underclothes.lua')
  11. minetest.create_detached_inventory('clothing_list', {
  12. allow_put = function(inv, listname, index, stack, player2)
  13. return 0
  14. end,
  15. allow_take = function(inv, listname, index, stack, player2)
  16. local name = player2 and player2:get_player_name() or ''
  17. if not creative.is_enabled_for(name) then
  18. return 0
  19. end
  20. return -1
  21. end,
  22. on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
  23. end,
  24. })
  25. local clothes = {}
  26. minetest.register_on_mods_loaded(function()
  27. for name, def in pairs(minetest.registered_items) do
  28. local group = def.groups or {}
  29. if group.clothing then
  30. clothes[name] = def
  31. end
  32. end
  33. local list = {}
  34. for name, def in pairs(clothes) do
  35. list[#list+1] = name
  36. end
  37. local clothing_inv = minetest.get_inventory({type = 'detached', name = 'clothing_list'})
  38. clothing_inv:set_size('main', #list)
  39. clothing_inv:set_list('main', list)
  40. clothing.inv_size = #list
  41. end)