Use tabs for indentation

This commit is contained in:
Hybrid Dog 2017-09-06 15:51:34 +02:00
parent e84433d41c
commit 46959e79d2

@ -1,7 +1,10 @@
if minetest.settings:get_bool("enable_item_pickup") ~= false then
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 key_triggered = minetest.settings:get_bool("enable_item_pickup_key") ~= false
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 key_triggered = minetest.settings:get_bool("enable_item_pickup_key")
~= false
local keytype
if key_triggered then
keytype = minetest.settings:get("item_pickup_keytype") or "Use"
@ -35,17 +38,21 @@ if minetest.settings:get_bool("enable_item_pickup") ~= false then
pos.y = pos.y+0.5
local inv = player:get_inventory()
local objectlist = minetest.get_objects_inside_radius(pos, pickup_radius)
local objectlist = minetest.get_objects_inside_radius(pos,
pickup_radius)
for _,object in ipairs(objectlist) do
if not object:is_player()
and object:get_luaentity()
and object:get_luaentity().name == "__builtin:item" then
local pos2 = object:getpos()
local distance = math.sqrt(((pos2.x - pos.x) * (pos2.x - pos.x)) + ((pos2.y - pos.y) * (pos2.y - pos.y))
+ ((pos2.z - pos.z) * (pos2.z - pos.z)))
local distance = vector.distance(pos, pos2)
if distance <= 1 then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if inv
and inv:room_for_item("main",
ItemStack(object:get_luaentity().itemstring)
) then
inv:add_item("main", ItemStack(
object:get_luaentity().itemstring))
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
@ -57,10 +64,14 @@ if minetest.settings:get_bool("enable_item_pickup") ~= false then
end
else
if object:get_luaentity().collect then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if inv
and inv:room_for_item("main",
ItemStack(object:get_luaentity().itemstring)
) then
local pos1 = pos
pos1.y = pos1.y+0.2
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y,
z=pos1.z-pos2.z}
vec.x = vec.x*3
vec.y = vec.y*3
vec.z = vec.z*3
@ -75,8 +86,13 @@ if minetest.settings:get_bool("enable_item_pickup") ~= false then
if not lua or not lua.itemstring then
return
end
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if inv:room_for_item("main",
ItemStack(object:get_luaentity(
).itemstring)
) then
inv:add_item("main",
ItemStack(object:get_luaentity(
).itemstring))
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
@ -114,7 +130,9 @@ if minetest.settings:get_bool("enable_item_drop") ~= false then
local inv
local diggerPos = pos
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
inv = digger:get_inventory()
diggerPos = digger:getpos()
end
@ -132,7 +150,8 @@ if minetest.settings:get_bool("enable_item_drop") ~= false then
if not inv or not inv:contains_item("main", ItemStack(name)) then
for i=1,count do
local adjustedPos = {x=diggerPos.x, y=diggerPos.y, z=diggerPos.z}
local adjustedPos = {x=diggerPos.x, y=diggerPos.y,
z=diggerPos.z}
local obj = minetest.add_item(adjustedPos, name)
if obj ~= nil then
@ -151,4 +170,6 @@ if minetest.settings:get_bool("enable_item_drop") ~= false then
end
end
if minetest.settings:get("log_mods") then minetest.log("action", "[Mod] item_drop loaded") end
if minetest.settings:get("log_mods") then
minetest.log("action", "[Mod] item_drop loaded")
end