mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-18 00:51:06 +01:00
Add CSM sprinting with double tap forward
This commit is contained in:
parent
d57db0444f
commit
31441a02e5
2 changed files with 25 additions and 2 deletions
|
@ -33,3 +33,8 @@ mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_de
|
||||||
keepInventory = false
|
keepInventory = false
|
||||||
|
|
||||||
dedicated_server_step = 0.001
|
dedicated_server_step = 0.001
|
||||||
|
|
||||||
|
# Clientmodding to support official client
|
||||||
|
enable_client_modding = true
|
||||||
|
csm_restriction_flags = 0
|
||||||
|
enable_mod_channels = true
|
||||||
|
|
|
@ -31,9 +31,11 @@ minetest.register_on_joinplayer(function(player)
|
||||||
sprinting = false,
|
sprinting = false,
|
||||||
timeOut = 0,
|
timeOut = 0,
|
||||||
shouldSprint = false,
|
shouldSprint = false,
|
||||||
|
clientSprint = false,
|
||||||
lastPos = player:get_pos(),
|
lastPos = player:get_pos(),
|
||||||
sprintDistance = 0,
|
sprintDistance = 0,
|
||||||
fov = 1.0
|
fov = 1.0,
|
||||||
|
channel = minetest.mod_channel_join("mcl_sprint:" .. playerName),
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
@ -41,6 +43,11 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
players[playerName] = nil
|
players[playerName] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function cancelClientSprinting(name)
|
||||||
|
players[name].channel:send_all("")
|
||||||
|
players[name].clientSprint = false
|
||||||
|
end
|
||||||
|
|
||||||
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
|
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
|
||||||
local player = minetest.get_player_by_name(playerName)
|
local player = minetest.get_player_by_name(playerName)
|
||||||
if players[playerName] then
|
if players[playerName] then
|
||||||
|
@ -97,6 +104,16 @@ local function get_top_node_tile(param2, paramtype2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_on_modchannel_message(function(channel_name, sender, message)
|
||||||
|
if channel_name == "mcl_sprint:" .. sender then
|
||||||
|
players[sender].clientSprint = minetest.is_yes(message)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
cancelClientSprinting(player:get_player_name())
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
--Get the gametime
|
--Get the gametime
|
||||||
local gameTime = minetest.get_gametime()
|
local gameTime = minetest.get_gametime()
|
||||||
|
@ -107,7 +124,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if player ~= nil then
|
if player ~= nil then
|
||||||
local ctrl = player:get_player_control()
|
local ctrl = player:get_player_control()
|
||||||
--Check if the player should be sprinting
|
--Check if the player should be sprinting
|
||||||
if ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
if players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
||||||
players[playerName]["shouldSprint"] = true
|
players[playerName]["shouldSprint"] = true
|
||||||
else
|
else
|
||||||
players[playerName]["shouldSprint"] = false
|
players[playerName]["shouldSprint"] = false
|
||||||
|
@ -160,6 +177,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Prevent sprinting if hungry or sleeping
|
-- Prevent sprinting if hungry or sleeping
|
||||||
if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then
|
if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then
|
||||||
sprinting = false
|
sprinting = false
|
||||||
|
cancelClientSprinting(playerName)
|
||||||
else
|
else
|
||||||
sprinting = true
|
sprinting = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue