2019-03-17 01:50:27 +00:00
|
|
|
physics = {}
|
|
|
|
|
|
|
|
local players = {}
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
players[player:get_player_name()] = {}
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
players[player:get_player_name()] = nil
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function update(name)
|
|
|
|
assert(players[name])
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
local override = {
|
|
|
|
speed = 1,
|
|
|
|
jump = 1,
|
|
|
|
gravity = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, layer in pairs(players[name]) do
|
|
|
|
for attr, val in pairs(layer) do
|
|
|
|
override[attr] = override[attr] * val
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
player:set_physics_override(override)
|
|
|
|
end
|
|
|
|
|
|
|
|
function physics.set(pname, name, modifiers)
|
2019-03-26 01:58:58 +00:00
|
|
|
if not players[pname] then
|
|
|
|
return
|
|
|
|
end
|
2019-03-17 01:50:27 +00:00
|
|
|
|
2019-03-26 01:58:58 +00:00
|
|
|
players[pname][name] = modifiers
|
2019-03-17 01:50:27 +00:00
|
|
|
update(pname)
|
|
|
|
end
|
|
|
|
|
|
|
|
function physics.remove(pname, name)
|
2019-03-26 01:58:58 +00:00
|
|
|
if not players[pname] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2019-03-17 01:50:27 +00:00
|
|
|
players[pname][name] = nil
|
|
|
|
update(pname)
|
|
|
|
end
|