Add sprint (#8)

This commit is contained in:
MinetestSam 2020-09-16 19:22:29 +05:30 committed by GitHub
parent 68457b6b66
commit dcadd7744f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -66,6 +66,7 @@ dofile(MP.."/register_nodes.lua")
dofile(MP.."/shop.lua")
dofile(MP .. "/extender.lua")
dofile(MP .. "/tools.lua")
dofile(MP .. "/sprint.lua")
----------------------
-- Helper Functions --

16
sprint.lua Normal file
View File

@ -0,0 +1,16 @@
local players = {}
minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
players[name] = true
local control = player:get_player_control()
local sprint = control.aux1 and control.up
if sprint and players[name] then
player:set_physics_override({speed = 1.2})
else
player:set_physics_override({speed = 1})
players[name] = nil
end
end
end)