mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2025-07-15 14:50:38 +02:00
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:
16
bags.lua
16
bags.lua
@ -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
|
||||
|
Reference in New Issue
Block a user