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

merge server with github

This commit is contained in:
Ombridride
2014-11-29 15:40:55 +01:00
parent 2f89e14839
commit b86fd8cfa9
279 changed files with 7543 additions and 1338 deletions

View File

@ -1,9 +1,10 @@
Sprint Mod For Minetest by GunshipPenguin
Allows the player to sprint by double tapping w. By default,
sprinting will make the player travel 80% faster and allow him/her
to jump 10% higher. Also adds a stamina bar that goes down when the
player sprints and goes up when he/she isn't sprinting.
Allows the player to sprint by either double tapping w or pressing e.
By default, sprinting will make the player travel 80% faster and
allow him/her to jump 10% higher. Also adds a stamina bar that goes
down when the player sprints and goes up when he/she isn't
sprinting.
Licence: CC0 (see COPYING file)
@ -12,6 +13,13 @@ Licence: CC0 (see COPYING file)
This mod can be configured by changing the variables declared in
the start of init.lua. The following is a brief explanation of each
one.
SPRINT_METHOD (default 1)
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
speed turned on, you will run very, very fast. You can toggle this
by pressing j.
SPRINT_SPEED (default 1.5)
@ -39,6 +47,7 @@ you want unlimited sprinting.
SPRINT_TIMEOUT (default 0.5)
Only used if SPRINT_METHOD = 0.
How much time the player has after releasing w, to press w again and
start sprinting. Setting this too high will result in unwanted
sprinting and setting it too low will result in it being

123
mods/sprint/esprint.lua Normal file
View File

@ -0,0 +1,123 @@
--[[
Sprint mod for Minetest by GunshipPenguin
To the extent possible under law, the author(s)
have dedicated all copyright and related and neighboring rights
to this software to the public domain worldwide. This software is
distributed without any warranty.
]]
local players = {}
local staminaHud = {}
minetest.register_on_joinplayer(function(player)
playerName = player:get_player_name()
players[playerName] = {
sprinting = false,
timeOut = 0,
stamina = SPRINT_STAMINA,
epressed = false,
hud = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
size = {x=24, y=24},
text = "stamina.png",
number = 20,
alignment = {x=0,y=1},
offset = {x=-320, y=-186},
}
),
}
end)
minetest.register_on_leaveplayer(function(player)
playerName = player:get_player_name()
players[playerName] = nil
end)
minetest.register_globalstep(function(dtime)
--Get the gametime
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
--Check if they are pressing the e key
players[playerName]["epressed"] = player:get_player_control()["aux1"]
--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
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 = "default_dirt.png",
})
end
end
end
--Adjust player states
if players[playerName]["epressed"] == true and playerInfo["timeOut"] == 0 then --Stopped
setSprinting(playerName, true)
elseif players[playerName]["epressed"] == false then
setSprinting(playerName, false)
end
if playerInfo["timeOut"] > 0 then
playerInfo["timeOut"] = playerInfo["timeOut"] - dtime
if playerInfo["timeOut"] < 0 then
playerInfo["timeOut"] = 0
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)
minetest.chat_send_player(playerName, "Votre sprint s'arrete, plus d'endurance ! Your sprint stamina has run out !")
playerInfo["timeOut"] = 1
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
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
--Update the players's hud sprint stamina bar
local numBars = (playerInfo["stamina"]/SPRINT_STAMINA)*20
player:hud_change(playerInfo["hud"], "number", numBars)
end
end
end)
function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
players[playerName]["sprinting"] = sprinting
if sprinting == true then
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
elseif sprinting == false then
player:set_physics_override({speed=1.0,jump=1.0})
end
return true
end
return false
end

123
mods/sprint/esprint.lua~ Normal file
View File

@ -0,0 +1,123 @@
--[[
Sprint mod for Minetest by GunshipPenguin
To the extent possible under law, the author(s)
have dedicated all copyright and related and neighboring rights
to this software to the public domain worldwide. This software is
distributed without any warranty.
]]
local players = {}
local staminaHud = {}
minetest.register_on_joinplayer(function(player)
playerName = player:get_player_name()
players[playerName] = {
sprinting = false,
timeOut = 0,
stamina = SPRINT_STAMINA,
epressed = false,
hud = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
size = {x=24, y=24},
text = "stamina.png",
number = 20,
alignment = {x=0,y=1},
offset = {x=-320, y=-186},
}
),
}
end)
minetest.register_on_leaveplayer(function(player)
playerName = player:get_player_name()
players[playerName] = nil
end)
minetest.register_globalstep(function(dtime)
--Get the gametime
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
--Check if they are pressing the e key
players[playerName]["epressed"] = player:get_player_control()["aux1"]
--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
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 = "default_dirt.png",
})
end
end
end
--Adjust player states
if players[playerName]["epressed"] == true and playerInfo["timeOut"] == 0 then --Stopped
setSprinting(playerName, true)
elseif players[playerName]["epressed"] == false then
setSprinting(playerName, false)
end
if playerInfo["timeOut"] > 0 then
playerInfo["timeOut"] = playerInfo["timeOut"] - dtime
if playerInfo["timeOut"] < 0 then
playerInfo["timeOut"] = 0
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)
minetest.chat_send_player(playerName, "Your sprint stamina has run out")
playerInfo["timeOut"] = 1
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
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
--Update the players's hud sprint stamina bar
local numBars = (playerInfo["stamina"]/SPRINT_STAMINA)*20
player:hud_change(playerInfo["hud"], "number", numBars)
end
end
end)
function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
players[playerName]["sprinting"] = sprinting
if sprinting == true then
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
elseif sprinting == false then
player:set_physics_override({speed=1.0,jump=1.0})
end
return true
end
return false
end

View File

@ -8,129 +8,17 @@ distributed without any warranty.
]]
--Configuration variables, these are all explained in README.md
local SPRINT_SPEED = 1.35
local SPRINT_JUMP = 1.1
local SPRINT_STAMINA = 10
local SPRINT_TIMEOUT = 0.5
local SPRINT_WARN = true
STOP_ON_CLICK = true --If true, sprinting will stop when either the left mouse button or the right mouse button is pressed
SPRINT_METHOD = 1
SPRINT_SPEED = 1.35
SPRINT_JUMP = 1.1
SPRINT_STAMINA = 10
SPRINT_TIMEOUT = 0.5 --Only used if SPRINT_METHOD = 0
local players = {}
local staminaHud = {}
minetest.register_on_joinplayer(function(player)
playerName = player:get_player_name()
players[playerName] = {
state = 0,
timeOut = 0,
stamina = SPRINT_STAMINA,
moving = false,
hud = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
size = {x=24, y=24},
text = "stamina.png",
number = 20,
alignment = {x=0,y=1},
offset = {x=-320, y=-186},
}
),
}
end)
minetest.register_on_leaveplayer(function(player)
playerName = player:get_player_name()
players[playerName] = nil
end)
minetest.register_globalstep(function(dtime)
--Get the gametime
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
--Check if they are moving or not
players[playerName]["moving"] = player:get_player_control()["up"]
-- s'arrete si le joueur fait un clique gauche ou droit
if player:get_player_control()["RMB"] or player:get_player_control()["LMB"] and STOP_ON_CLICK == true then
players[playerName]["state"] = 0
player:set_physics_override({speed=1.0, jump=1.0})
end
--If the player has tapped w longer than SPRINT_TIMEOUT ago, set his/her state to 0
if playerInfo["state"] == 2 then
if playerInfo["timeOut"] + SPRINT_TIMEOUT < gameTime then
players[playerName]["timeOut"] = nil
setState(playerName, 0)
end
--If the player is sprinting, create particles behind him/her
elseif playerInfo["state"] == 3 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 = "default_dirt.png",
})
end
end
end
--Adjust player states
if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped
setState(playerName, 0)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 0 then --Moving
setState(playerName, 1)
elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed
setState(playerName, 2)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting
setState(playerName, 3)
end
--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["state"] == 3 then
playerInfo["stamina"] = playerInfo["stamina"] - dtime
if playerInfo["stamina"] <= 0 then
playerInfo["stamina"] = 0
setState(playerName, 0)
if SPRINT_WARN then
minetest.chat_send_player(playerName, "Votre sprint s'arrete, plus d'endurance ! Your sprint stamina has run out !")
end
end
--Increase player's stamina if he/she is not sprinting and his/her stamina is less than SPRINT_STAMINA
elseif playerInfo["state"] ~= 3 and playerInfo["stamina"] < SPRINT_STAMINA then
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
--Update the players's hud sprint stamina bar
local numBars = (playerInfo["stamina"]/SPRINT_STAMINA)*20
player:hud_change(playerInfo["hud"], "number", numBars)
end
end
end)
function setState(playerName, state) --Sets the state of a player (0=stopped, 1=moving, 2=primed, 3=sprinting)
local player = minetest.get_player_by_name(playerName)
local gameTime = minetest.get_gametime()
if players[playerName] then
players[playerName]["state"] = state
if state == 0 then--Stopped
player:set_physics_override({speed=1.0,jump=1.0})
elseif state == 2 then --Primed
players[playerName]["timeOut"] = gameTime
elseif state == 3 then --Sprinting
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
end
return true
end
return false
if SPRINT_METHOD == 0 then
dofile(minetest.get_modpath("sprint") .. "/wsprint.lua")
elseif SPRINT_METHOD == 1 then
dofile(minetest.get_modpath("sprint") .. "/esprint.lua")
else
minetest.log("error", "Sprint Mod - SPRINT_METHOD is not set properly, using e to sprint")
dofile(minetest.get_modpath("sprint") .. "/esprint.lua")
end

121
mods/sprint/wsprint.lua Normal file
View File

@ -0,0 +1,121 @@
--[[
Sprint mod for Minetest by GunshipPenguin
To the extent possible under law, the author(s)
have dedicated all copyright and related and neighboring rights
to this software to the public domain worldwide. This software is
distributed without any warranty.
]]
local players = {}
local staminaHud = {}
minetest.register_on_joinplayer(function(player)
playerName = player:get_player_name()
players[playerName] = {
state = 0,
timeOut = 0,
stamina = SPRINT_STAMINA,
moving = false,
hud = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1},
size = {x=24, y=24},
text = "stamina.png",
number = 20,
alignment = {x=0,y=1},
offset = {x=-320, y=-186},
}
),
}
end)
minetest.register_on_leaveplayer(function(player)
playerName = player:get_player_name()
players[playerName] = nil
end)
minetest.register_globalstep(function(dtime)
--Get the gametime
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
--Check if they are moving or not
players[playerName]["moving"] = player:get_player_control()["up"]
--If the player has tapped w longer than SPRINT_TIMEOUT ago, set his/her state to 0
if playerInfo["state"] == 2 then
if playerInfo["timeOut"] + SPRINT_TIMEOUT < gameTime then
players[playerName]["timeOut"] = nil
setState(playerName, 0)
end
--If the player is sprinting, create particles behind him/her
elseif playerInfo["state"] == 3 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 = "default_dirt.png",
})
end
end
end
--Adjust player states
if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped
setState(playerName, 0)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 0 then --Moving
setState(playerName, 1)
elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed
setState(playerName, 2)
elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting
setState(playerName, 3)
end
--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["state"] == 3 then
playerInfo["stamina"] = playerInfo["stamina"] - dtime
if playerInfo["stamina"] <= 0 then
playerInfo["stamina"] = 0
setState(playerName, 0)
end
--Increase player's stamina if he/she is not sprinting and his/her stamina is less than SPRINT_STAMINA
elseif playerInfo["state"] ~= 3 and playerInfo["stamina"] < SPRINT_STAMINA then
playerInfo["stamina"] = playerInfo["stamina"] + dtime
end
--Update the players's hud sprint stamina bar
local numBars = (playerInfo["stamina"]/SPRINT_STAMINA)*20
player:hud_change(playerInfo["hud"], "number", numBars)
end
end
end)
function setState(playerName, state) --Sets the state of a player (0=stopped, 1=moving, 2=primed, 3=sprinting)
local player = minetest.get_player_by_name(playerName)
local gameTime = minetest.get_gametime()
if players[playerName] then
players[playerName]["state"] = state
if state == 0 then--Stopped
player:set_physics_override({speed=1.0,jump=1.0})
elseif state == 2 then --Primed
players[playerName]["timeOut"] = gameTime
elseif state == 3 then --Sprinting
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
end
return true
end
return false
end