mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2024-11-19 22:03:43 +01: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:
parent
a70ffb1509
commit
4403b696be
2
api.lua
2
api.lua
@ -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
|
||||||
|
|
||||||
|
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>
|
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
|
||||||
@ -118,17 +120,19 @@ local function save_bags_metadata(player, bags_inv)
|
|||||||
is_empty = false
|
is_empty = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local meta = player:get_meta()
|
||||||
if is_empty then
|
if is_empty then
|
||||||
player:set_attribute("unified_inventory:bags", nil)
|
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
|
||||||
|
3
mod.conf
3
mod.conf
@ -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.
|
||||||
|
@ -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",
|
||||||
|
@ -174,7 +174,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
|
|
||||||
if fields["set_waypoint"..i] then
|
if fields["set_waypoint"..i] then
|
||||||
hit = true
|
hit = true
|
||||||
local pos = player:getpos()
|
local pos = player:get_pos()
|
||||||
pos.x = math.floor(pos.x)
|
pos.x = math.floor(pos.x)
|
||||||
pos.y = math.floor(pos.y)
|
pos.y = math.floor(pos.y)
|
||||||
pos.z = math.floor(pos.z)
|
pos.z = math.floor(pos.z)
|
||||||
|
Loading…
Reference in New Issue
Block a user