Miroir du dépôt skinsdb.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4KB

  1. local S = minetest.get_translator("skinsdb")
  2. unified_inventory.register_page("skins", {
  3. get_formspec = function(player)
  4. local skin = skins.get_player_skin(player)
  5. local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]"..skins.get_skin_info_formspec(skin)..
  6. "button[.75,3;6.5,.5;skins_page;"..S("Change").."]"
  7. return {formspec=formspec}
  8. end,
  9. })
  10. unified_inventory.register_button("skins", {
  11. type = "image",
  12. image = "skins_button.png",
  13. tooltip = S("Skins"),
  14. })
  15. local function get_formspec(player)
  16. local context = skins.get_formspec_context(player)
  17. local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]"..
  18. skins.get_skin_selection_formspec(player, context, -0.2)
  19. return formspec
  20. end
  21. unified_inventory.register_page("skins_page", {
  22. get_formspec = function(player)
  23. return {formspec=get_formspec(player)}
  24. end
  25. })
  26. -- click button handlers
  27. minetest.register_on_player_receive_fields(function(player, formname, fields)
  28. if fields.skins then
  29. unified_inventory.set_inventory_formspec(player, "craft")
  30. return
  31. end
  32. if formname ~= "" then
  33. return
  34. end
  35. local context = skins.get_formspec_context(player)
  36. local action = skins.on_skin_selection_receive_fields(player, context, fields)
  37. if action == 'set' then
  38. unified_inventory.set_inventory_formspec(player, "skins")
  39. elseif action == 'page' then
  40. unified_inventory.set_inventory_formspec(player, "skins_page")
  41. end
  42. end)