Fix bug for other speed-manipulators
This commit is contained in:
parent
c68d0705db
commit
cf89f830a2
35
init.lua
35
init.lua
|
@ -1,16 +1,39 @@
|
|||
--TODO: other physics-speed-manipulator(e.g. crystallshoes) manipulate but it not work because it is all the time at 0.4 or 1. But you should walk only 40% of normalvelocity.
|
||||
--TODO: maybe some glitches?
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local meta = player:get_meta()
|
||||
meta:set_float("speed", 1)
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
local meta = player:get_meta()
|
||||
local name = player:get_player_name()
|
||||
if minetest.get_node(player:get_pos()).name == "default:water_source" then
|
||||
meta:set_int("in_liquid", 1)
|
||||
else
|
||||
meta:set_int("in_liquid", 0)
|
||||
end
|
||||
|
||||
--print( meta:get_int("in_liquid") )
|
||||
local tempmeta = meta:get_int("in_liquid")
|
||||
|
||||
if tempmeta==1 then
|
||||
if math.floor(player:get_physics_override().speed*10)/10 ~= 0.4 then
|
||||
meta:set_float("speed", player:get_physics_override().speed)
|
||||
end
|
||||
player:set_physics_override({
|
||||
speed = 0.4
|
||||
})
|
||||
else
|
||||
player:set_physics_override({
|
||||
speed = 1
|
||||
})
|
||||
elseif tempmeta==0 then
|
||||
if math.floor(player:get_physics_override().speed*10)/10 == 0.4 then
|
||||
player:set_physics_override({
|
||||
speed = meta:get_float("speed")
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue