Allow disabling the pickup key

To support lecagy setting names, I added two functions. They use the old setting only if the new one is not set.
(I'm not sure if enable_item_pickup_key is a valid legacy setting…)

I did not test this commit thoroughly.
This commit is contained in:
HybridDog 2019-05-29 20:44:40 +02:00
parent 1e9e73e978
commit 70b3386322

@ -23,25 +23,39 @@ item_drop = {
end, end,
} }
if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false and local function legacy_setting_getbool(name_new, name_old, default)
minetest.settings:get_bool("enable_item_pickup") ~= false then local v = minetest.settings:get_bool(name_new)
local pickup_gain = tonumber( if v == nil then
minetest.settings:get("item_drop.pickup_sound_gain")) or v = minetest.settings:get_bool(name_new)
tonumber(minetest.settings:get("item_pickup_gain")) or 0.2 end
if default then
return v ~= false
end
return v
end
local function legacy_setting_getnumber(name_new, name_old, default)
return tonumber(minetest.settings:get(name_new))
or tonumber(minetest.settings:get(name_old))
or default
end
if legacy_setting_getbool("item_drop.enable_item_pickup",
"enable_item_pickup", true) then
local pickup_gain = legacy_setting_getnumber("item_drop.pickup_sound_gain",
"item_pickup_gain", 0.2)
local pickup_particle = local pickup_particle =
minetest.settings:get_bool("item_drop.pickup_particle") ~= false minetest.settings:get_bool("item_drop.pickup_particle", true)
local pickup_radius = tonumber( local pickup_radius = legacy_setting_getnumber("item_drop.pickup_radius",
minetest.settings:get("item_drop.pickup_radius")) or "item_pickup_radius", 0.75)
tonumber(minetest.settings:get("item_pickup_radius")) or 0.75
local magnet_radius = tonumber( local magnet_radius = tonumber(
minetest.settings:get("item_drop.magnet_radius")) or -1 minetest.settings:get("item_drop.magnet_radius")) or -1
local magnet_time = tonumber( local magnet_time = tonumber(
minetest.settings:get("item_drop.magnet_time")) or 5.0 minetest.settings:get("item_drop.magnet_time")) or 5.0
local pickup_age = tonumber( local pickup_age = tonumber(
minetest.settings:get("item_drop.pickup_age")) or 0.5 minetest.settings:get("item_drop.pickup_age")) or 0.5
local key_triggered = minetest.settings:get_bool( local key_triggered = legacy_setting_getbool("item_drop.enable_pickup_key",
"item_drop.enable_pickup_key") or "enable_item_pickup_key", true)
minetest.settings:get_bool("enable_item_pickup_key") ~= false
local key_invert = minetest.settings:get_bool( local key_invert = minetest.settings:get_bool(
"item_drop.pickup_keyinvert") or false "item_drop.pickup_keyinvert") or false
local keytype local keytype
@ -314,8 +328,7 @@ minetest.settings:get_bool("enable_item_pickup") ~= false then
minetest.after(3.0, pickup_step) minetest.after(3.0, pickup_step)
end end
if minetest.settings:get_bool("item_drop.enable_item_drop") ~= false and if legacy_setting_getbool("item_drop.enable_item_drop", "enable_item_drop", true)
minetest.settings:get_bool("enable_item_drop") ~= false
and not minetest.settings:get_bool("creative_mode") then and not minetest.settings:get_bool("creative_mode") then
function minetest.handle_node_drops(pos, drops) function minetest.handle_node_drops(pos, drops)
for i = 1,#drops do for i = 1,#drops do