Replace deprecated functions with newer ones.

- Update api.lua

- Store bags on player metadata

- Update register.lua

- Update mod.conf

These commits makes more compatibility with MT/MTG 5.0.0+ versions.
However, these commits breaks compatibility with the 0.4-series.
This commit is contained in:
Panquesito7 2019-06-16 01:00:16 -05:00 committed by GitHub
parent a70ffb1509
commit 66f64ec59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 8 deletions

View File

@ -187,7 +187,7 @@ end
function unified_inventory.go_home(player) function unified_inventory.go_home(player)
local pos = unified_inventory.home_pos[player:get_player_name()] local pos = unified_inventory.home_pos[player:get_player_name()]
if pos then if pos then
player:setpos(pos) player:set_pos(pos)
end end
end end

View File

@ -1,7 +1,9 @@
-- Bags for Minetest --[[
Bags for Minetest
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com> Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
-- License: GPLv3 License: GPLv3
--]]
local S = unified_inventory.gettext local S = unified_inventory.gettext
local F = minetest.formspec_escape local F = minetest.formspec_escape
@ -119,16 +121,18 @@ local function save_bags_metadata(player, bags_inv)
end end
end end
if is_empty then if is_empty then
player:set_attribute("unified_inventory:bags", nil) local meta = player:get_meta()
meta:set_string("unified_inventory:bags", nil)
else else
player:set_attribute("unified_inventory:bags", meta:set_string("unified_inventory:bags",
minetest.serialize(bags)) minetest.serialize(bags))
end end
end end
local function load_bags_metadata(player, bags_inv) local function load_bags_metadata(player, bags_inv)
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
local bags_meta = player:get_attribute("unified_inventory:bags") local meta = player:get_meta()
local bags_meta = meta:get_string("unified_inventory:bags")
local bags = bags_meta and minetest.deserialize(bags_meta) or {} local bags = bags_meta and minetest.deserialize(bags_meta) or {}
local dirty_meta = false local dirty_meta = false
if not bags_meta then if not bags_meta then

View File

@ -1 +1,4 @@
name = unified_inventory name = unified_inventory
depends = default
optional_depends = creative, sfinv, intllib, datastorage, farming
description = Unified Inventory replaces the default survival and creative inventory. It adds a nicer interface and a number of features, such as a crafting guide.

View File

@ -48,7 +48,7 @@ unified_inventory.register_button("home_gui_set", {
action = function(player) action = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {home=true}) then if minetest.check_player_privs(player_name, {home=true}) then
unified_inventory.set_home(player, player:getpos()) unified_inventory.set_home(player, player:get_pos())
local home = unified_inventory.home_pos[player_name] local home = unified_inventory.home_pos[player_name]
if home ~= nil then if home ~= nil then
minetest.sound_play("dingdong", minetest.sound_play("dingdong",