44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
end
elseif ctx.how.state == 'prog' then
local d = ctx.how.delta
local p = user.action.prog.sprint
-- is the player currently holding any of WASD
local isMoving = bit.band(0x0f, user.entity:get_player_control_bits()) ~= 0
if p and isMoving then
user.cooldownTimes.stamina = minetest.get_gametime()
p.cb = p.cb + cost*d
if p.cb >= 5 then
user:statDelta('stamina', -p.cb)
p.cb = 0
if user:effectiveStat 'stamina' < cost then halt() end
end
end
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
end
elseif ctx.how.state == 'prog' then
local d = ctx.how.delta
local p = user.action.prog.sprint
-- is the player currently holding any of WASD
local isMoving = bit.band(0x0f, user.entity:get_player_control_bits()) ~= 0
if p and isMoving then
user.cooldownTimes.stamina = core.get_gametime()
p.cb = p.cb + cost*d
if p.cb >= 5 then
user:statDelta('stamina', -p.cb)
p.cb = 0
if user:effectiveStat 'stamina' < cost then halt() end
end
end
|