Awards: remove unified_inventory and sfinv support

This commit is contained in:
cora 2023-10-23 22:00:39 +02:00
parent cfb4227889
commit 8191e1f51a
3 changed files with 1 additions and 64 deletions

View File

@ -2,7 +2,7 @@ name = awards
title = Awards
author = rubenwardy
description = Adds awards to Minetest, and an API to register new ones.
optional_depends = sfinv,unified_inventory,default
optional_depends = default
license = MIT
forum = https://forum.minetest.net/viewtopic.php?t=4870
version = 3.0.0

View File

@ -21,13 +21,6 @@ minetest.register_chatcommand("awards", {
else
awards.show_to(name, name, nil, false)
end
if (param == "disable" or param == "enable") and minetest.global_exists("sfinv") then
local player = minetest.get_player_by_name(name)
if player then
sfinv.set_player_inventory_formspec(player)
end
end
end
})

View File

@ -165,59 +165,3 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return true
end)
if minetest.get_modpath("sfinv") then
sfinv.register_page("awards:awards", {
title = S("Awards"),
on_enter = function(self, player, context)
context.awards_idx = 1
end,
is_in_nav = function(self, player, context)
local data = awards.player(player:get_player_name())
return not data.disabled
end,
get = function(self, player, context)
local name = player:get_player_name()
return sfinv.make_formspec(player, context,
awards.get_formspec(name, name, context.awards_idx),
false)
end,
on_player_receive_fields = function(self, player, context, fields)
if fields.awards then
local event = minetest.explode_textlist_event(fields.awards)
if event.type == "CHG" then
context.awards_idx = event.index
sfinv.set_player_inventory_formspec(player, context)
end
end
end
})
local function check_and_reshow(name)
local player = minetest.get_player_by_name(name)
if not player then
return
end
local context = sfinv.get_or_create_context(player)
if context.page ~= "awards:awards" then
return
end
sfinv.set_player_inventory_formspec(player, context)
end
awards.register_on_unlock(check_and_reshow)
end
if minetest.get_modpath("unified_inventory") ~= nil then
unified_inventory.register_button("awards", {
type = "image",
image = "awards_ui_icon.png",
tooltip = S("Awards"),
action = function(player)
local name = player:get_player_name()
awards.show_to(name, name, nil, false)
end,
})
end