mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-12-22 22:02:26 +01:00
Proper global settingtypes
This commit is contained in:
parent
67025939e7
commit
dbb43c2ed1
39
init.lua
39
init.lua
@ -1,25 +1,26 @@
|
|||||||
local enable_item_pickup = minetest.settings:get_bool("enable_item_pickup")
|
local pickup = minetest.settings:get_bool("enable_item_pickup")
|
||||||
if enable_item_pickup == nil then enable_item_pickup = true end
|
local drops = minetest.settings:get_bool("enable_item_drops")
|
||||||
local enable_item_drops = minetest.settings:get_bool("enable_item_drops")
|
local key = minetest.settings:get_bool("enable_item_pickup_key")
|
||||||
if enable_item_drops == nil then enable_item_drops = true end
|
local keytype = minetest.settings:get("item_pickup_keytype") or "Use"
|
||||||
local item_pickup_key = minetest.settings:get_bool("item_pickup_key")
|
local gain = tonumber(minetest.settings:get("item_pickup_gain")) or 0.4
|
||||||
if item_pickup_key == nil then item_pickup_key = true end
|
|
||||||
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 pickup == nil then pickup = true end
|
||||||
|
if drops == nil then drops = true end
|
||||||
|
if key == nil then key = true end
|
||||||
|
|
||||||
if enable_item_pickup then
|
local key_press = false
|
||||||
|
|
||||||
|
if pickup then
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
if item_pickup_keytype == "sneak" then
|
if keytype == "Sneak" then
|
||||||
item_pickup_key_press = player:get_player_control().sneak
|
key_press = player:get_player_control().sneak
|
||||||
elseif item_pickup_keytype == "ad" then
|
elseif keytype == "LeftAndRight" then
|
||||||
item_pickup_key_press = player:get_player_control().left and player:get_player_control().right
|
key_press = player:get_player_control().left and player:get_player_control().right
|
||||||
else
|
else
|
||||||
item_pickup_key_press = player:get_player_control().aux1
|
key_press = player:get_player_control().aux1
|
||||||
end
|
end
|
||||||
if item_pickup_key_press or not item_pickup_key then
|
if key_press or not key then
|
||||||
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
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
|
||||||
@ -32,7 +33,7 @@ if enable_item_pickup then
|
|||||||
if object:get_luaentity().itemstring ~= "" then
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
to_player = player:get_player_name(),
|
to_player = player:get_player_name(),
|
||||||
gain = item_pickup_gain,
|
gain = gain,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
object:get_luaentity().itemstring = ""
|
object:get_luaentity().itemstring = ""
|
||||||
@ -68,7 +69,7 @@ if enable_item_pickup then
|
|||||||
if object:get_luaentity().itemstring ~= "" then
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
to_player = player:get_player_name(),
|
to_player = player:get_player_name(),
|
||||||
gain = item_pickup_gain,
|
gain = gain,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
object:get_luaentity().itemstring = ""
|
object:get_luaentity().itemstring = ""
|
||||||
@ -92,7 +93,7 @@ if enable_item_pickup then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if enable_item_drops then
|
if drops then
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
function minetest.handle_node_drops(pos, drops, digger)
|
||||||
local inv
|
local inv
|
||||||
if minetest.settings:get_bool("creative_mode") and digger and digger:is_player() then
|
if minetest.settings:get_bool("creative_mode") and digger and digger:is_player() then
|
||||||
|
14
settingtypes.txt
Normal file
14
settingtypes.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#Pick up items automatically
|
||||||
|
enable_item_pickup (Enable item pickups) bool true
|
||||||
|
|
||||||
|
#Drop items in-world on dig
|
||||||
|
enable_item_drops (Enable item drops) bool true
|
||||||
|
|
||||||
|
#Use a key to pick up items
|
||||||
|
enable_item_pickup_key (Use pickup key) bool true
|
||||||
|
|
||||||
|
#What keytype to use as pickup key
|
||||||
|
item_pickup_keytype (Pickup keytype) enum Use Use,Sneak,LeftAndRight
|
||||||
|
|
||||||
|
#The volume of the pickup sound
|
||||||
|
item_pickup_gain (Pickup sound gain) float 0.4
|
Loading…
Reference in New Issue
Block a user