init.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- support for i18n
  2. local S = armor_i18n.gettext
  3. local F = minetest.formspec_escape
  4. if not minetest.global_exists("inventory_plus") then
  5. minetest.log("warning", S("3d_armor_ip: Mod loaded but unused."))
  6. return
  7. end
  8. armor.formspec = "size[8,8.5]button[6,0;2,0.5;main;"..F(S("Back")).."]"..armor.formspec
  9. armor:register_on_update(function(player)
  10. local name = player:get_player_name()
  11. local formspec = armor:get_armor_formspec(name, true)
  12. local page = player:get_inventory_formspec()
  13. if page:find("detached:"..name.."_armor") then
  14. inventory_plus.set_inventory_formspec(player, formspec)
  15. end
  16. end)
  17. if minetest.get_modpath("crafting") then
  18. inventory_plus.get_formspec = function(player, page)
  19. end
  20. end
  21. minetest.register_on_joinplayer(function(player)
  22. inventory_plus.register_button(player,"armor", S("Armor"))
  23. end)
  24. minetest.register_on_player_receive_fields(function(player, formname, fields)
  25. if fields.armor then
  26. local name = armor:get_valid_player(player, "[on_player_receive_fields]")
  27. if not name then
  28. return
  29. end
  30. local formspec = armor:get_armor_formspec(name, true)
  31. inventory_plus.set_inventory_formspec(player, formspec)
  32. end
  33. end)