player_callbacks.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. minetest.register_on_joinplayer(function(player)
  2. local name = player:get_player_name()
  3. --Minetest doesn't allow for easily changing player inventories shown in the hotbar.
  4. --To counter this the inventory is swapped between 'main' and 'builder' depending on player mode.
  5. player:get_inventory():set_size('main', 32)
  6. player:get_inventory():set_size('builder', 32)
  7. player:get_inventory():set_size('clothing', 24)
  8. local clothing = minetest.create_detached_inventory(name..'_clothing', {
  9. on_put = function(inv, listname, index, stack, player)
  10. gamer.get_clothes(player)
  11. end,
  12. on_take = function(inv, listname, index, stack, player)
  13. gamer.get_clothes(player)
  14. end,
  15. on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
  16. gamer.get_clothes(player)
  17. end,
  18. allow_put = function(inv, listname, index, put_stack, player)
  19. local clothes = put_stack:get_name()
  20. if minetest.get_item_group(clothes, 'clothing') > 0 then
  21. return 1
  22. else
  23. return 0
  24. end
  25. end
  26. })
  27. clothing:set_size('slots', 18)
  28. gamer.player_attached[player:get_player_name()] = false
  29. gamer.player_set_model(player, 'gamer_model.b3d')
  30. player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
  31. player:hud_set_hotbar_image("gui_hotbar.png")
  32. player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
  33. player:set_formspec_prepend('bgcolor[#222222;false]')
  34. gamer.retrieve_clothes(player)
  35. gamer.get_clothes(player)
  36. if player.get_lighting then
  37. local light = player:get_lighting()
  38. light.shadows.intensity = 0.5
  39. player:set_lighting(light)
  40. end
  41. end)