1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-16 23:40:31 +01:00

fix wrong used variable last_[x|y|z]_pos

fix variable last_[x|y|z]_pos used by player, not for all players
This commit is contained in:
crabman77 2015-03-09 19:00:26 +01:00
parent 1df5b49a05
commit c5ad8e22a1

View File

@ -53,9 +53,7 @@ local counter=0--*****************
--local SOUNDVOLUME = 1 --local SOUNDVOLUME = 1
--local MUSICVOLUME = 1 --local MUSICVOLUME = 1
local sound_vol = 1 local sound_vol = 1
local last_x_pos = 0 local players_pos = {}
local last_y_pos = 0
local last_z_pos = 0
local node_under_feet local node_under_feet
local node_at_upper_body local node_at_upper_body
local node_at_lower_body local node_at_lower_body
@ -313,20 +311,21 @@ local get_ambience = function(player)
local standing_in_water = false local standing_in_water = false
local pos = player:getpos() local pos = player:getpos()
get_immediate_nodes(pos) get_immediate_nodes(pos)
local player_name = player:get_player_name()
if last_x_pos ~=pos.x or last_z_pos ~=pos.z then if player_name == nil or players_pos[player_name] == nil then return end
if players_pos[player_name]["last_x_pos"] ~=pos.x or players_pos[player_name]["last_z_pos"] ~=pos.z then
player_is_moving_horiz = true player_is_moving_horiz = true
end end
if pos.y > last_y_pos+.5 then if pos.y > players_pos[player_name]["last_y_pos"]+.5 then
player_is_climbing = true player_is_climbing = true
end end
if pos.y < last_y_pos-.5 then if pos.y < players_pos[player_name]["last_y_pos"]-.5 then
player_is_descending = true player_is_descending = true
end end
last_x_pos =pos.x players_pos[player_name]["last_x_pos"] = pos.x
last_z_pos =pos.z players_pos[player_name]["last_z_pos"] = pos.z
last_y_pos =pos.y players_pos[player_name]["last_y_pos"] = pos.y
if string.find(node_at_upper_body, "default:water") then if string.find(node_at_upper_body, "default:water") then
if music then if music then
@ -774,6 +773,20 @@ minetest.register_globalstep(function(dtime)
end end
end) end)
minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name()
local pos = player:getpos()
players_pos[player_name] = {}
players_pos[player_name]["last_x_pos"] = pos.x
players_pos[player_name]["last_z_pos"] = pos.z
players_pos[player_name]["last_y_pos"] = pos.y
end)
minetest.register_on_leaveplayer(function(player)
local player_name = player:get_player_name()
players_pos[player_name] = nil
end)
--[[ --[[
minetest.register_chatcommand("svol", { minetest.register_chatcommand("svol", {
params = "<svol>", params = "<svol>",