forked from minetest-mods/item_drop
Short code a bit
This commit is contained in:
parent
81d32527f3
commit
962d0a3889
33
init.lua
33
init.lua
|
@ -1,15 +1,12 @@
|
||||||
local pickup = minetest.settings:get_bool("enable_item_pickup")
|
local pickup = minetest.settings:get_bool("enable_item_pickup") ~= false
|
||||||
local drop = minetest.settings:get_bool("enable_item_drop")
|
local drop = minetest.settings:get_bool("enable_item_drop") ~= false
|
||||||
local key = minetest.settings:get_bool("enable_item_pickup_key")
|
local key = minetest.settings:get_bool("enable_item_pickup_key") ~= false
|
||||||
|
|
||||||
if pickup == nil then pickup = true end
|
|
||||||
if drop == nil then drop = true end
|
|
||||||
if key == nil then key = true end
|
|
||||||
|
|
||||||
local keytype = minetest.settings:get("item_pickup_keytype") or "Use"
|
local keytype = minetest.settings:get("item_pickup_keytype") or "Use"
|
||||||
local pickup_gain = tonumber(minetest.settings:get("item_pickup_gain")) or 0.4
|
local pickup_gain = tonumber(minetest.settings:get("item_pickup_gain")) or 0.4
|
||||||
local pickup_radius = tonumber(minetest.settings:get("item_pickup_radius")) or 0.75
|
local pickup_radius = tonumber(minetest.settings:get("item_pickup_radius")) or 0.75
|
||||||
|
|
||||||
|
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
|
||||||
if pickup then
|
if pickup then
|
||||||
|
@ -25,20 +22,22 @@ if pickup then
|
||||||
local control = player:get_player_control()
|
local control = player:get_player_control()
|
||||||
|
|
||||||
if keytype == "Use" then
|
if keytype == "Use" then
|
||||||
if control.aux1 == true then keys_pressed = true end
|
keys_pressed = control.aux1
|
||||||
elseif keytype == "Sneak" then
|
elseif keytype == "Sneak" then
|
||||||
if control.sneak == true then keys_pressed = true end
|
keys_pressed = control.sneak
|
||||||
elseif keytype == "LeftAndRight" then -- LeftAndRight combination
|
elseif keytype == "LeftAndRight" then -- LeftAndRight combination
|
||||||
if control.left and control.right then keys_pressed = true end
|
keys_pressed = control.left and control.right
|
||||||
elseif keytype == "RMB" then
|
elseif keytype == "RMB" then
|
||||||
if control.RMB == true then keys_pressed = true end
|
keys_pressed = control.RMB
|
||||||
elseif keytype == "SneakAndRMB" then -- SneakAndRMB combination
|
elseif keytype == "SneakAndRMB" then -- SneakAndRMB combination
|
||||||
if control.sneak and control.RMB then keys_pressed = true end
|
keys_pressed = control.sneak and control.RMB
|
||||||
end
|
end
|
||||||
|
|
||||||
if keys_pressed or not key then
|
if not keys_pressed and key
|
||||||
|
or (damage_enabled and player:get_hp() <= 0) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
pos.y = pos.y+0.5
|
pos.y = pos.y+0.5
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
@ -80,7 +79,7 @@ if pickup then
|
||||||
|
|
||||||
minetest.after(1, function()
|
minetest.after(1, function()
|
||||||
local lua = object:get_luaentity()
|
local lua = object:get_luaentity()
|
||||||
if object == nil or lua == nil or lua.itemstring == nil then
|
if not lua or not lua.itemstring then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
|
@ -107,8 +106,6 @@ if pickup then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user