mirror of
https://github.com/minetest-mods/hbsprint.git
synced 2024-12-22 21:32:24 +01:00
Add support for playerphysics
This commit is contained in:
parent
13cc9d522a
commit
05712baabf
15
init.lua
15
init.lua
@ -20,8 +20,9 @@ local sprint_timer = 0
|
|||||||
local stamina_timer = 0
|
local stamina_timer = 0
|
||||||
local breath_timer = 0
|
local breath_timer = 0
|
||||||
|
|
||||||
local hudbars = minetest.get_modpath("hudbars") or false
|
local mod_hudbars = minetest.get_modpath("hudbars") or false
|
||||||
local monoids = minetest.get_modpath("player_monoids") or false
|
local mod_player_monoids = minetest.get_modpath("player_monoids") or false
|
||||||
|
local mod_playerphysics = minetest.get_modpath("playerphysics") or false
|
||||||
local starve
|
local starve
|
||||||
if minetest.get_modpath("hbhunger") then
|
if minetest.get_modpath("hbhunger") then
|
||||||
starve = "hbhunger"
|
starve = "hbhunger"
|
||||||
@ -38,9 +39,12 @@ end
|
|||||||
|
|
||||||
local function start_sprint(player)
|
local function start_sprint(player)
|
||||||
if player:get_meta():get("hbsprint:sprinting") == "false" then
|
if player:get_meta():get("hbsprint:sprinting") == "false" then
|
||||||
if monoids then
|
if mod_player_monoids then
|
||||||
player_monoids.speed:add_change(player, speed, "hbsprint:speed")
|
player_monoids.speed:add_change(player, speed, "hbsprint:speed")
|
||||||
player_monoids.jump:add_change(player, jump, "hbsprint:jump")
|
player_monoids.jump:add_change(player, jump, "hbsprint:jump")
|
||||||
|
elseif mod_playerphysics then
|
||||||
|
playerphysics.add_physics_factor(player, "speed", "hbsprint:speed", speed)
|
||||||
|
playerphysics.add_physics_factor(player, "jump", "hbsprint:jump", jump)
|
||||||
else
|
else
|
||||||
player:set_physics_override({speed = speed, jump = jump})
|
player:set_physics_override({speed = speed, jump = jump})
|
||||||
end
|
end
|
||||||
@ -49,9 +53,12 @@ end
|
|||||||
|
|
||||||
local function stop_sprint(player)
|
local function stop_sprint(player)
|
||||||
if player:get_meta():get("hbsprint:sprinting") == "true" then
|
if player:get_meta():get("hbsprint:sprinting") == "true" then
|
||||||
if monoids then
|
if mod_player_monoids then
|
||||||
player_monoids.speed:del_change(player, "hbsprint:speed")
|
player_monoids.speed:del_change(player, "hbsprint:speed")
|
||||||
player_monoids.jump:del_change(player, "hbsprint:jump")
|
player_monoids.jump:del_change(player, "hbsprint:jump")
|
||||||
|
elseif mod_playerphysics then
|
||||||
|
playerphysics.remove_physics_factor(player, "speed", "hbsprint:speed")
|
||||||
|
playerphysics.remove_physics_factor(player, "jump", "hbsprint:jump")
|
||||||
else
|
else
|
||||||
player:set_physics_override({speed = 1, jump = 1})
|
player:set_physics_override({speed = 1, jump = 1})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user