Prevent sprinting if hunger level <= 6
This commit is contained in:
parent
2e7ce77985
commit
d36beaf64f
|
@ -19,6 +19,7 @@ What a player has to do to start sprinting. 0 = double tap w, 1 = press e.
|
||||||
Note that if you have the fast privlige, and have the fast
|
Note that if you have the fast privlige, and have the fast
|
||||||
speed turned on, you will run very, very fast. You can toggle this
|
speed turned on, you will run very, very fast. You can toggle this
|
||||||
by pressing j.
|
by pressing j.
|
||||||
|
NOTE: Method 0 is UNTESTED!
|
||||||
|
|
||||||
mcl_sprint.SPEED (default 1.5)
|
mcl_sprint.SPEED (default 1.5)
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
playerplus
|
playerplus
|
||||||
|
mcl_hunger
|
||||||
|
|
|
@ -61,8 +61,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
--Adjust player states
|
--Adjust player states
|
||||||
if players[playerName]["shouldSprint"] == true then --Stopped
|
if players[playerName]["shouldSprint"] == true then --Stopped
|
||||||
local sprinting
|
local sprinting
|
||||||
-- Prevent sprinting if standing on soul sand
|
-- Prevent sprinting if standing on soul sand or hungry
|
||||||
if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" then
|
if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" or mcl_hunger.get_hunger(player) <= 6 then
|
||||||
sprinting = false
|
sprinting = false
|
||||||
else
|
else
|
||||||
sprinting = true
|
sprinting = true
|
||||||
|
|
|
@ -15,6 +15,7 @@ mcl_sprint.SPEED = 1.3
|
||||||
mcl_sprint.TIMEOUT = 0.5 --Only used if mcl_sprint.METHOD = 0
|
mcl_sprint.TIMEOUT = 0.5 --Only used if mcl_sprint.METHOD = 0
|
||||||
|
|
||||||
if mcl_sprint.METHOD == 0 then
|
if mcl_sprint.METHOD == 0 then
|
||||||
|
-- UNTESTED
|
||||||
dofile(minetest.get_modpath("mcl_sprint") .. "/wsprint.lua")
|
dofile(minetest.get_modpath("mcl_sprint") .. "/wsprint.lua")
|
||||||
elseif mcl_sprint.METHOD == 1 then
|
elseif mcl_sprint.METHOD == 1 then
|
||||||
dofile(minetest.get_modpath("mcl_sprint") .. "/esprint.lua")
|
dofile(minetest.get_modpath("mcl_sprint") .. "/esprint.lua")
|
||||||
|
|
|
@ -60,6 +60,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Prevent sprinting if standing on soul sand or hungry
|
||||||
|
local can_sprint = (playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand") and (mcl_hunger.get_hunger(player) <= 6)
|
||||||
--Adjust player states
|
--Adjust player states
|
||||||
if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped
|
if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped
|
||||||
setState(playerName, 0)
|
setState(playerName, 0)
|
||||||
|
@ -67,18 +69,16 @@ minetest.register_globalstep(function(dtime)
|
||||||
setState(playerName, 1)
|
setState(playerName, 1)
|
||||||
elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed
|
elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed
|
||||||
local sprinting
|
local sprinting
|
||||||
-- Prevent sprinting if standing on soul sand
|
if can_sprint then
|
||||||
if not playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then
|
|
||||||
setState(playerName, 2)
|
|
||||||
else
|
|
||||||
setState(playerName, 0)
|
setState(playerName, 0)
|
||||||
|
else
|
||||||
|
setState(playerName, 2)
|
||||||
end
|
end
|
||||||
elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting
|
elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting
|
||||||
-- Prevent sprinting if standing on soul sand
|
if can_sprint then
|
||||||
if not playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then
|
|
||||||
setState(playerName, 3)
|
|
||||||
else
|
|
||||||
setState(playerName, 1)
|
setState(playerName, 1)
|
||||||
|
else
|
||||||
|
setState(playerName, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue