From 09a7281be838f517d0b595551c7915fe0ea957a4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 9 Jul 2021 05:33:12 +0200 Subject: [PATCH] Update deprecated use of get_/set_attribute --- init.lua | 12 +++++++----- mod.conf | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 2b7d7df..50d6454 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,7 @@ playerphysics = {} local function calculate_attribute_product(player, attribute) - local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) + local a = minetest.deserialize(player:get_meta():get_string("playerphysics:physics")) local product = 1 if a == nil or a[attribute] == nil then return product @@ -16,7 +16,8 @@ local function calculate_attribute_product(player, attribute) end function playerphysics.add_physics_factor(player, attribute, id, value) - local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) + local meta = player:get_meta() + local a = minetest.deserialize(meta:get_string("playerphysics:physics")) if a == nil then a = { [attribute] = { [id] = value } } elseif a[attribute] == nil then @@ -24,20 +25,21 @@ function playerphysics.add_physics_factor(player, attribute, id, value) else a[attribute][id] = value end - player:set_attribute("playerphysics:physics", minetest.serialize(a)) + meta:set_string("playerphysics:physics", minetest.serialize(a)) local raw_value = calculate_attribute_product(player, attribute) player:set_physics_override({[attribute] = raw_value}) end function playerphysics.remove_physics_factor(player, attribute, id) - local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) + local meta = player:get_meta() + local a = minetest.deserialize(meta:get_string("playerphysics:physics")) if a == nil or a[attribute] == nil then -- Nothing to remove return else a[attribute][id] = nil end - player:set_attribute("playerphysics:physics", minetest.serialize(a)) + meta:set_string("playerphysics:physics", minetest.serialize(a)) local raw_value = calculate_attribute_product(player, attribute) player:set_physics_override({[attribute] = raw_value}) end diff --git a/mod.conf b/mod.conf index da01bf0..aec13ea 100644 --- a/mod.conf +++ b/mod.conf @@ -1 +1,2 @@ name = playerphysics +description = This mod makes it possible for multiple mods to modify player physics (speed, jumping strength, gravity) without conflict. -- 2.11.4.GIT