Fixed indentations in chainsaw.lua

This commit is contained in:
Phvli
2014-05-18 20:08:13 +03:00
parent 64c9a81264
commit aa2a55dcdd

View File

@ -18,11 +18,11 @@ end
-- technic_worldgen defines rubber trees if moretrees isn't installed -- technic_worldgen defines rubber trees if moretrees isn't installed
if minetest.get_modpath("technic_worldgen") or if minetest.get_modpath("technic_worldgen") or
minetest.get_modpath("moretrees") then minetest.get_modpath("moretrees") then
timber_nodenames["moretrees:rubber_tree_trunk_empty"] = true timber_nodenames["moretrees:rubber_tree_trunk_empty"] = true
timber_nodenames["moretrees:rubber_tree_trunk"] = true timber_nodenames["moretrees:rubber_tree_trunk"] = true
if chainsaw_leaves then if chainsaw_leaves then
timber_nodenames["moretrees:rubber_tree_leaves"] = true timber_nodenames["moretrees:rubber_tree_leaves"] = true
end end
end end
-- Support moretrees if it is there -- Support moretrees if it is there
@ -208,26 +208,26 @@ local function get_drop_pos(pos)
local drop_pos, node local drop_pos, node
repeat repeat
-- Randomize position for a new drop -- Randomize position for a new drop
drop_pos = { drop_pos = {
x = pos.x + math.random(-3, 3), x = pos.x + math.random(-3, 3),
y = pos.y - 1, y = pos.y - 1,
z = pos.z + math.random(-3, 3) z = pos.z + math.random(-3, 3)
} }
-- Move the newly-randomized position upwards until there's -- Move the newly-randomized position upwards until there's
-- no node in it or an unloaded block is found -- no node in it or an unloaded block is found
repeat repeat
drop_pos.y = drop_pos.y + 1 drop_pos.y = drop_pos.y + 1
node = minetest.get_node(drop_pos).name node = minetest.get_node(drop_pos).name
if node == "ignore" then if node == "ignore" then
-- On a rare chase where the block above the digging position is not -- On a rare chase where the block above the digging position is not
-- loaded yet, simply drop the nodes at the original digging position -- loaded yet, simply drop the nodes at the original digging position
return pos return pos
end end
until node == "air" until node == "air"
-- Make sure the drops will not end up too high on a tall ledge or a column -- Make sure the drops will not end up too high on a tall ledge or a column
until drop_pos.y < pos.y + 5 until drop_pos.y < pos.y + 5
@ -240,14 +240,14 @@ end
-- Saw down trees entry point -- Saw down trees entry point
local function chainsaw_dig_it(pos, player,current_charge) local function chainsaw_dig_it(pos, player,current_charge)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
minetest.record_protection_violation(pos, player:get_player_name()) minetest.record_protection_violation(pos, player:get_player_name())
return current_charge return current_charge
end end
local remaining_charge=current_charge local remaining_charge=current_charge
-- Save the currently installed dropping mechanism so we can restore it. -- Save the currently installed dropping mechanism so we can restore it.
local original_handle_node_drops = minetest.handle_node_drops local original_handle_node_drops = minetest.handle_node_drops
-- A bit of trickery here: use a different node drop callback -- A bit of trickery here: use a different node drop callback
-- and restore the original afterwards. -- and restore the original afterwards.
@ -279,30 +279,30 @@ end
minetest.register_tool("technic:chainsaw", { minetest.register_tool("technic:chainsaw", {
description = S("Chainsaw"), description = S("Chainsaw"),
inventory_image = "technic_chainsaw.png", inventory_image = "technic_chainsaw.png",
stack_max = 1, stack_max = 1,
wear_represents = "technic_RE_charge", wear_represents = "technic_RE_charge",
on_refill = technic.refill_RE_charge, on_refill = technic.refill_RE_charge,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return itemstack return itemstack
end end
local meta = minetest.deserialize(itemstack:get_metadata()) local meta = minetest.deserialize(itemstack:get_metadata())
if not meta or not meta.charge then if not meta or not meta.charge then
return return
end end
-- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes. -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes.
if meta.charge < chainsaw_charge_per_node then if meta.charge < chainsaw_charge_per_node then
return return
end end
local pos = minetest.get_pointed_thing_position(pointed_thing, above) local pos = minetest.get_pointed_thing_position(pointed_thing, above)
meta.charge = chainsaw_dig_it(pos, user, meta.charge) meta.charge = chainsaw_dig_it(pos, user, meta.charge)
technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge) technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge)
itemstack:set_metadata(minetest.serialize(meta)) itemstack:set_metadata(minetest.serialize(meta))
return itemstack return itemstack
end, end,
}) })
minetest.register_craft({ minetest.register_craft({