3 local function calculate_physic_product(player
, physic
)
4 local a
= minetest
.deserialize(player
:get_attribute("mcl_playerphysics:physics"))
6 if a
== nil or a
[physic
] == nil then
9 local factors
= a
[physic
]
10 if type(factors
) == "table" then
11 for id
, factor
in pairs(factors
) do
12 product
= product
* factor
18 function mcl_playerphysics
.add_physics_factor(player
, physic
, id
, value
)
19 local a
= minetest
.deserialize(player
:get_attribute("mcl_playerphysics:physics"))
21 a
= { [physic
] = { [id
] = value
} }
22 elseif a
[physic
] == nil then
23 a
[physic
] = { [id
] = value
}
27 player
:set_attribute("mcl_playerphysics:physics", minetest
.serialize(a
))
28 local raw_value
= calculate_physic_product(player
, physic
)
29 player
:set_physics_override({[physic
] = raw_value
})
32 function mcl_playerphysics
.remove_physics_factor(player
, physic
, id
)
33 local a
= minetest
.deserialize(player
:get_attribute("mcl_playerphysics:physics"))
34 if a
== nil or a
[physic
] == nil then
40 player
:set_attribute("mcl_playerphysics:physics", minetest
.serialize(a
))
41 local raw_value
= calculate_physic_product(player
, physic
)
42 player
:set_physics_override({[physic
] = raw_value
})