mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-14 15:11:05 +01:00
Move sprint vars into mcl_sprint table
This commit is contained in:
parent
94eb0b19e6
commit
341e8fadb2
4 changed files with 21 additions and 19 deletions
|
@ -13,14 +13,14 @@ 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)
|
||||
mcl_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)
|
||||
mcl_sprint.SPEED (default 1.5)
|
||||
|
||||
How fast the player will move when sprinting as opposed to normal
|
||||
movement speed. 1.0 represents normal speed so 1.5 would mean that a
|
||||
|
@ -28,25 +28,25 @@ sprinting player would travel 50% faster than a walking player and
|
|||
2.4 would mean that a sprinting player would travel 140% faster than
|
||||
a walking player.
|
||||
|
||||
SPRINT_JUMP (default 1.1)
|
||||
mcl_sprint.JUMP (default 1.1)
|
||||
|
||||
How high the player will jump when sprinting as opposed to normal
|
||||
jump height. Same as SPRINT_SPEED, just controls jump height while
|
||||
jump height. Same as mcl_sprint.SPEED, just controls jump height while
|
||||
sprinting rather than speed.
|
||||
|
||||
SPRINT_STAMINA (default 20)
|
||||
mcl_sprint.STAMINA (default 20)
|
||||
|
||||
How long the player can sprint for in seconds. Each player has a
|
||||
stamina variable assigned to them, it is initially set to
|
||||
SPRINT_STAMINA and can go no higher. When the player is sprinting,
|
||||
mcl_sprint.STAMINA and can go no higher. When the player is sprinting,
|
||||
this variable ticks down once each second, and when it reaches 0,
|
||||
the player stops sprinting. It ticks back up when the player isn't
|
||||
sprinting and stops at SPRINT_STAMINA. Set this to a huge value if
|
||||
sprinting and stops at mcl_sprint.STAMINA. Set this to a huge value if
|
||||
you want unlimited sprinting.
|
||||
|
||||
SPRINT_TIMEOUT (default 0.5)
|
||||
mcl_sprint.TIMEOUT (default 0.5)
|
||||
|
||||
Only used if SPRINT_METHOD = 0.
|
||||
Only used if mcl_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
|
||||
|
|
|
@ -83,7 +83,7 @@ function setSprinting(playerName, sprinting) --Sets the state of a player (0=sto
|
|||
-- Don't overwrite physics when standing on soul sand
|
||||
if playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then
|
||||
if sprinting == true then
|
||||
player:set_physics_override({speed=SPRINT_SPEED})
|
||||
player:set_physics_override({speed=mcl_sprint.SPEED})
|
||||
elseif sprinting == false then
|
||||
player:set_physics_override({speed=1.0})
|
||||
end
|
||||
|
|
|
@ -8,15 +8,17 @@ distributed without any warranty.
|
|||
]]
|
||||
|
||||
--Configuration variables, these are all explained in README.md
|
||||
SPRINT_METHOD = 1
|
||||
SPRINT_SPEED = 1.3
|
||||
SPRINT_TIMEOUT = 0.5 --Only used if SPRINT_METHOD = 0
|
||||
mcl_sprint = {}
|
||||
|
||||
if SPRINT_METHOD == 0 then
|
||||
mcl_sprint.METHOD = 1
|
||||
mcl_sprint.SPEED = 1.3
|
||||
mcl_sprint.TIMEOUT = 0.5 --Only used if mcl_sprint.METHOD = 0
|
||||
|
||||
if mcl_sprint.METHOD == 0 then
|
||||
dofile(minetest.get_modpath("mcl_sprint") .. "/wsprint.lua")
|
||||
elseif SPRINT_METHOD == 1 then
|
||||
elseif mcl_sprint.METHOD == 1 then
|
||||
dofile(minetest.get_modpath("mcl_sprint") .. "/esprint.lua")
|
||||
else
|
||||
minetest.log("error", "[mcl_sprint] SPRINT_METHOD is not set properly, using [E] to sprint.")
|
||||
minetest.log("error", "[mcl_sprint] mcl_sprint.METHOD is not set properly, using [E] to sprint.")
|
||||
dofile(minetest.get_modpath("mcl_sprint") .. "/esprint.lua")
|
||||
end
|
||||
|
|
|
@ -32,9 +32,9 @@ minetest.register_globalstep(function(dtime)
|
|||
--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 the player has tapped w longer than mcl_sprint.TIMEOUT ago, set his/her state to 0
|
||||
if playerInfo["state"] == 2 then
|
||||
if playerInfo["timeOut"] + SPRINT_TIMEOUT < gameTime then
|
||||
if playerInfo["timeOut"] + mcl_sprint.TIMEOUT < gameTime then
|
||||
players[playerName]["timeOut"] = nil
|
||||
setState(playerName, 0)
|
||||
end
|
||||
|
@ -98,7 +98,7 @@ function setState(playerName, state) --Sets the state of a player (0=stopped, 1=
|
|||
elseif state == 2 then --Primed
|
||||
players[playerName]["timeOut"] = gameTime
|
||||
elseif state == 3 then --Sprinting
|
||||
player:set_physics_override({speed=SPRINT_SPEED})
|
||||
player:set_physics_override({speed=mcl_sprint.SPEED})
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue