mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-12-23 06:12:30 +01:00
Fix key triggering disabling
This commit is contained in:
parent
6de1402ebc
commit
88df92b125
39
init.lua
39
init.lua
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user