sprint fixed

This commit is contained in:
aegroto 2018-09-24 12:30:46 +02:00
parent 914b095c91
commit 8eb0c7c93c
2 changed files with 13 additions and 6 deletions

View File

@ -14,11 +14,18 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
players[playerName]["sprinting"] = sprinting
local currentPhy = player:get_physics_override()
local newPhy = currentPhy
if sprinting == true then
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
newPhy.speed = newPhy.speed + SPRINT_SPEED
newPhy.jump = newPhy.jump + SPRINT_JUMP
elseif sprinting == false then
player:set_physics_override({speed=1.0,jump=1.0})
newPhy.speed = newPhy.speed - SPRINT_SPEED
newPhy.jump = newPhy.jump - SPRINT_JUMP
end
player:set_physics_override(newPhy)
return true
end
return false
@ -89,9 +96,9 @@ minetest.register_globalstep(function(dtime)
end
--Adjust player states
if players[playerName]["shouldSprint"] == true then --Stopped
if players[playerName]["shouldSprint"] == true and players[playerName].sprinting == false then --Stopped
setSprinting(playerName, true)
elseif players[playerName]["shouldSprint"] == false then
elseif players[playerName]["shouldSprint"] == false and players[playerName].sprinting == true then
setSprinting(playerName, false)
end

View File

@ -9,8 +9,8 @@ distributed without any warranty.
--Configuration variables, these are all explained in README.md
SPRINT_METHOD = 1
SPRINT_SPEED = 1.5
SPRINT_JUMP = 1.1
SPRINT_SPEED = .5
SPRINT_JUMP = .1
SPRINT_STAMINA = 10
SPRINT_TIMEOUT = 0.5 --Only used if SPRINT_METHOD = 0