Better comments.

master
aa6 2017-01-18 17:33:31 +03:00
parent af42e5b213
commit 3bdd2277b5
3 changed files with 17 additions and 13 deletions

View File

@ -1 +1 @@
0.4.24 0.4.25

View File

@ -72,6 +72,7 @@ end
-- Adds/subtracts stamina to player. -- Adds/subtracts stamina to player.
-- --
-- minetest_wadsprint.api.addstamina(player_name, 0.1) -- To add 10% of STAMINA_MAX_VALUE. -- minetest_wadsprint.api.addstamina(player_name, 0.1) -- To add 10% of STAMINA_MAX_VALUE.
-- minetest_wadsprint.api.addstamina(player_name, -0.1) -- To subtract 10% of STAMINA_MAX_VALUE.
-- --
function minetest_wadsprint.api.addstamina(player_name,stamina_rate_change) function minetest_wadsprint.api.addstamina(player_name,stamina_rate_change)
local player = minetest_wadsprint.stats[player_name] local player = minetest_wadsprint.stats[player_name]
@ -91,14 +92,16 @@ function minetest_wadsprint.stamina_update_cycle(player)
minetest_wadsprint.SPRINT_STAMINA_DECREASE_PER_UPDATE_PERIOD_COEFFICIENT minetest_wadsprint.SPRINT_STAMINA_DECREASE_PER_UPDATE_PERIOD_COEFFICIENT
) )
) )
elseif player.stamina < minetest_wadsprint.STAMINA_MAX_VALUE then else
minetest_wadsprint.set_stamina(player, if player.stamina < minetest_wadsprint.STAMINA_MAX_VALUE then
player.stamina + minetest_wadsprint.set_stamina(player,
( player.stamina +
minetest_wadsprint.STAMINA_MAX_VALUE * (
minetest_wadsprint.SPRINT_STAMINA_INCREASE_PER_UPDATE_PERIOD_COEFFICIENT minetest_wadsprint.STAMINA_MAX_VALUE *
minetest_wadsprint.SPRINT_STAMINA_INCREASE_PER_UPDATE_PERIOD_COEFFICIENT
)
) )
) end
end end
end end
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -122,10 +125,10 @@ end
-- Main use of this function is to put player in a state when pressing "W" would trigger the -- Main use of this function is to put player in a state when pressing "W" would trigger the
-- sprinting state thus you won't need to hold "A"+"D" to keep sprinting. Also it alters player -- sprinting state thus you won't need to hold "A"+"D" to keep sprinting. Also it alters player
-- physics to workaround lag between pressing "W" and actual sprinting. So if player is ready to -- physics to workaround lag between pressing "W" and actual sprinting. So if player is ready to
-- sprint it is sure that his physics is already in sprinting state and he can not afraid to fall -- sprint he is sure that his physics is already in sprinting state and he can not afraid to fall
-- while jumping from a tree to tree just because the lag between pressing "W" and sprinting state -- while jumping from a tree to tree just because the lag between pressing "W" and switching to
-- would be too big. At the same time being only ready to sprint and not actually sprinting does -- sprinting state would be too big. At the same time being only ready to sprint but not actually
-- not decreases the stamina because decreasing stamina for not sprinting is unfair. -- sprinting does not decreases the stamina because decreasing stamina for not sprinting is unfair.
function minetest_wadsprint.switch_to_ready_to_sprint(player) function minetest_wadsprint.switch_to_ready_to_sprint(player)
if player.is_ready_to_sprint == false then if player.is_ready_to_sprint == false then
if player.is_sprinting_physics_on == false then if player.is_sprinting_physics_on == false then
@ -141,7 +144,8 @@ end
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------- switch_to_sprinting() -- --------------------------------------------------------------------------- switch_to_sprinting() --
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
-- Sprinting means that player is moving forward. If player isn't moving then he isn't sprinting. -- Sprinting means that player has altered physics and is moving forward. If player isn't moving
-- then he isn't sprinting.
function minetest_wadsprint.switch_to_sprinting(player) function minetest_wadsprint.switch_to_sprinting(player)
if player.is_sprinting == false then if player.is_sprinting == false then
if player.is_sprinting_physics_on == false then if player.is_sprinting_physics_on == false then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB