Replace deprecated functions with newer ones (#131)

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 03:26:40 -05:00
committed by SmallJoker
parent a70ffb1509
commit 4403b696be
5 changed files with 16 additions and 9 deletions

View File

@ -1,7 +1,9 @@
-- Bags for Minetest
--[[
Bags for Minetest
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
-- License: GPLv3
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
License: GPLv3
--]]
local S = unified_inventory.gettext
local F = minetest.formspec_escape
@ -118,17 +120,19 @@ local function save_bags_metadata(player, bags_inv)
is_empty = false
end
end
local meta = player:get_meta()
if is_empty then
player:set_attribute("unified_inventory:bags", nil)
meta:set_string("unified_inventory:bags", nil)
else
player:set_attribute("unified_inventory:bags",
meta:set_string("unified_inventory:bags",
minetest.serialize(bags))
end
end
local function load_bags_metadata(player, bags_inv)
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 dirty_meta = false
if not bags_meta then