Add optional pickup key, either sneak, use or a+d key. Add settable sound gain.

This commit is contained in:
tacotexmex 2017-06-26 15:57:23 +02:00
parent 04f75caeb3
commit a523b5a574

@ -1,9 +1,22 @@
local enable_item_pickup = minetest.settings:get_bool("enable_item_pickup") or true
local enable_item_drops = minetest.settings:get_bool("enable_item_drops") or true
local item_pickup_key = minetest.settings:get_bool("item_pickup_key") or false
local item_pickup_keytype = minetest.settings:get("item_pickup_keytype") or "use"
local item_pickup_gain = tonumber(minetest.settings:get("item_pickup_gain")) or 0.4
local item_pickup_key_press = false
if enable_item_pickup then
minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do
if item_pickup_keytype == "sneak" then
item_pickup_key_press = player:get_player_control().sneak
elseif item_pickup_keytype == "ad" then
item_pickup_key_press = player:get_player_control().left and player:get_player_control().right
else
item_pickup_key_press = player:get_player_control().aux1
end
if item_pickup_key_press or not item_pickup_key then
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
local pos = player:getpos()
pos.y = pos.y+0.5
@ -16,7 +29,7 @@ if enable_item_pickup then
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
gain = 0.4,
gain = item_pickup_gain,
})
end
object:get_luaentity().itemstring = ""
@ -52,7 +65,7 @@ if enable_item_pickup then
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
gain = 0.4,
gain = item_pickup_gain,
})
end
object:get_luaentity().itemstring = ""
@ -73,7 +86,8 @@ if enable_item_pickup then
end
end
end
end)
end)
end
if enable_item_drops then
function minetest.handle_node_drops(pos, drops, digger)