1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 14:16:06 +02:00

Added all hudbars by @Wuzzy2

- Removed hud (incompatible)
 - Copied all hunger.lua's values in new hunger.lua (hbhunger)
 - Added hbhunger, hbarmor
 - Updated sprint mod
This commit is contained in:
LeMagnesium
2015-06-16 19:22:40 +02:00
parent 3f9ffdcb8f
commit bd86d9d8f4
42 changed files with 864 additions and 1006 deletions

View File

@ -17,7 +17,7 @@ minetest.register_on_joinplayer(function(player)
sprinting = false,
timeOut = 0,
stamina = SPRINT_STAMINA,
epressed = false,
shouldSprint = false,
}
if SPRINT_HUDBARS_USED then
hb.init_hudbar(player, "sprint")
@ -26,7 +26,7 @@ minetest.register_on_joinplayer(function(player)
hud_elem_type = "statbar",
position = {x=0.5,y=1},
size = {x=24, y=24},
text = "stamina.png",
text = "sprint_stamina_icon.png",
number = 20,
alignment = {x=0,y=1},
offset = {x=-320, y=-186},
@ -38,93 +38,71 @@ minetest.register_on_leaveplayer(function(player)
local playerName = player:get_player_name()
players[playerName] = nil
end)
local gameTime = 0
minetest.register_globalstep(function(dtime)
--Get the gametime
gameTime = gameTime + dtime
local gameTime = minetest.get_gametime()
--Loop through all connected players
for playerName,playerInfo in pairs(players) do
local player = minetest.get_player_by_name(playerName)
if player ~= nil then
--no sprint if stand (if in keybinding setting menu, checkbox ["Use" = climb down] is checked , climb down use sprint)
--Check if they are pressing the e key
local pressed = player:get_player_control()["aux1"]
if pressed and (player:get_player_control()["up"] or player:get_player_control()["down"] or player:get_player_control()["left"] or player:get_player_control()["right"]) then
players[playerName]["epressed"] = true
--Check if the player should be sprinting
if player:get_player_control()["aux1"] and player:get_player_control()["up"] then
players[playerName]["shouldSprint"] = true
else
players[playerName]["epressed"] = false
end
--Stop sprinting if the player is pressing the LMB or RMB
if player:get_player_control()["LMB"] or player:get_player_control()["RMB"] then
setSprinting(playerName, false)
playerInfo["timeOut"] = 3
players[playerName]["shouldSprint"] = false
end
if gameTime > 0.4 then
gameTime = 0
local pos = player:getpos()
-- From playerplus :
-- am I near a cactus?
pos.y = pos.y + 0.1
local near = minetest.find_node_near(pos, 1, "default:cactus")
if near then
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-1)
end
gameTime = 0
local pos = player:getpos()
-- From playerplus :
-- am I near a cactus?
pos.y = pos.y + 0.1
local near = minetest.find_node_near(pos, 1, "default:cactus")
if near then
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-1)
end
end
--If the player is sprinting, create particles behind him/her
if playerInfo["sprinting"] == true then
local numParticles = math.random(1, 2)
local playerPos = player:getpos()
local playerNode = minetest.get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]})
if playerNode["name"] ~= "air" then
for i=1, numParticles, 1 do
minetest.add_particle({
pos = {x=playerPos["x"]+math.random(-1,1)*math.random()/2,y=playerPos["y"]+0.1,z=playerPos["z"]+math.random(-1,1)*math.random()/2},
vel = {x=0, y=5, z=0},
acc = {x=0, y=-13, z=0},
expirationtime = math.random(),
size = math.random()+0.5,
collisiondetection = true,
vertical = false,
texture = "sprint_particle.png",
})
end
--If the player is sprinting, create particles behind him/her
if playerInfo["sprinting"] == true and gameTime % 0.1 == 0 then
local numParticles = math.random(1, 2)
local playerPos = player:getpos()
local playerNode = minetest.get_node({x=playerPos["x"], y=playerPos["y"]-1, z=playerPos["z"]})
if playerNode["name"] ~= "air" then
for i=1, numParticles, 1 do
minetest.add_particle({
pos = {x=playerPos["x"]+math.random(-1,1)*math.random()/2,y=playerPos["y"]+0.1,z=playerPos["z"]+math.random(-1,1)*math.random()/2},
vel = {x=0, y=5, z=0},
acc = {x=0, y=-13, z=0},
expirationtime = math.random(),
size = math.random()+0.5,
collisiondetection = true,
vertical = false,
texture = "sprint_particle.png",
})
end
end
end
--Adjust player states
if players[playerName]["epressed"] == true and playerInfo["timeOut"] == 0 then --Stopped
if players[playerName]["shouldSprint"] == true then --Stopped
setSprinting(playerName, true)
elseif players[playerName]["epressed"] == false then
elseif players[playerName]["shouldSprint"] == false then
setSprinting(playerName, false)
end
if playerInfo["timeOut"] > 0 then
playerInfo["timeOut"] = playerInfo["timeOut"] - dtime
if playerInfo["timeOut"] < 0 then
playerInfo["timeOut"] = 0
--Lower the player's stamina by dtime if he/she is sprinting and set his/her state to 0 if stamina is zero
if playerInfo["sprinting"] == true then
playerInfo["stamina"] = playerInfo["stamina"] - dtime
if playerInfo["stamina"] <= 0 then
playerInfo["stamina"] = 0
setSprinting(playerName, false)
end
else
--Lower the player's stamina by dtime if he/she is sprinting and set his/her state to 0 if stamina is zero
if playerInfo["sprinting"] == true then
playerInfo["stamina"] = playerInfo["stamina"] - dtime
if playerInfo["stamina"] <= 0 then
playerInfo["stamina"] = 0
setSprinting(playerName, false)
playerInfo["timeOut"] = 1
minetest.sound_play("default_breathless",{object=player})
end
end
end
--Increase player's stamina if he/she is not sprinting and his/her stamina is less than SPRINT_STAMINA
if playerInfo["sprinting"] == false and playerInfo["stamina"] < SPRINT_STAMINA then
elseif playerInfo["sprinting"] == false and playerInfo["stamina"] < SPRINT_STAMINA then
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
-- Cap stamina at SPRINT_STAMINA

View File

@ -16,7 +16,7 @@ SPRINT_TIMEOUT = 0.5 --Only used if SPRINT_METHOD = 0
if minetest.get_modpath("hudbars") ~= nil then
hb.register_hudbar("sprint", 0xFFFFFF, "Stamina",
{ bar = "sprint_stamina_bar.png", icon = "stamina.png" },
{ bar = "sprint_stamina_bar.png", icon = "sprint_stamina_icon.png" },
SPRINT_STAMINA, SPRINT_STAMINA,
false, "%s: %.1f/%.1f")
SPRINT_HUDBARS_USED = true

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B