Fix key triggering disabling

This commit is contained in:
Hybrid Dog 2017-09-08 20:57:05 +02:00
parent 22763d3b06
commit bf0bb807fb

View File

@ -90,24 +90,39 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
end end
end end
local function pickupfunc(player) -- set keytype to the key name if possible
local keys_pressed = not key_triggered
local control = player:get_player_control()
if keytype == "Use" then if keytype == "Use" then
keys_pressed = control.aux1 keytype = "aux1"
elseif keytype == "Sneak" then elseif keytype == "Sneak" then
keys_pressed = control.sneak keytype = "sneak"
elseif keytype == "LeftAndRight" then -- LeftAndRight combination elseif keytype == "LeftAndRight" then -- LeftAndRight combination
keys_pressed = control.left and control.right keytype = 0
elseif keytype == "RMB" then
keys_pressed = control.RMB
elseif keytype == "SneakAndRMB" then -- SneakAndRMB combination elseif keytype == "SneakAndRMB" then -- SneakAndRMB combination
keys_pressed = control.sneak and control.RMB keytype = 1
end end
if keys_pressed == key_invert
-- tests if the player has the keys pressed to enable item picking
local function keys_pressed(player)
if not key_triggered then
return true
end
local control = player:get_player_control()
local keys_pressed
if keytype == 0 then -- LeftAndRight combination
keys_pressed = control.left and control.right
elseif keytpye == 1 then -- SneakAndRMB combination
keys_pressed = control.sneak and control.RMB
else
keys_pressed = control[keytype]
end
return keys_pressed ~= key_invert
end
local function pickupfunc(player)
if not keys_pressed(player)
or player:get_hp() <= 0 then or player:get_hp() <= 0 then
return return
end end