Sneaking actually makes player make less sound.

This commit is contained in:
Aaron Suen 2019-09-09 08:11:06 -04:00
parent a99ba82831
commit 9e20b3ce66
3 changed files with 20 additions and 5 deletions

View File

@ -11,8 +11,6 @@ ISSUES: Bugs, Cleanup and Refinements
- Experiment with making handholds glow faintly.
- Disable footstep sounds, soften inventory sounds while player sneaks.
- Redesign how falling_nodes pile up.
- Make sure nodes are not destroyed.
- Allow node displacement sideways?

View File

@ -10,7 +10,8 @@ local function wieldsound(player, idx, gain)
local t = {}
for k, v in pairs(def.sounds.dig) do t[k] = v end
t.pos = player:get_pos()
t.gain = gain
t.gain = gain or 1
if player:get_player_control().sneak then t.gain = t.gain / 4 end
return function() minetest.sound_play(t.name, t) end
end
return function() end

View File

@ -1,8 +1,10 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest
= minetest
local minetest, pairs
= minetest, pairs
-- LUALOCALS > ---------------------------------------------------------
local footsteps = {}
minetest.register_on_joinplayer(function(player)
local inv = player:get_inventory()
inv:set_size("main", 8)
@ -18,6 +20,7 @@ minetest.register_on_joinplayer(function(player)
-- Allow slight zoom for screenshots
zoom_fov = 60
})
footsteps[player:get_player_name()] = true
end)
minetest.register_allow_player_inventory_action(function(_, action)
@ -25,3 +28,16 @@ minetest.register_allow_player_inventory_action(function(_, action)
end)
minetest.unregister_chatcommand("kill")
minetest.register_globalstep(function()
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local value = not player:get_player_control().sneak
if footsteps[name] ~= value then
player:set_properties({
makes_footstep_sound = value
})
footsteps[name] = value
end
end
end)