mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-26 10:50:33 +01:00
Add protection support to tools
This adds support to the chainsaw, mining drill, mining laser, sonic screwdriver, and tree tap.
This commit is contained in:
parent
5cf765b2f1
commit
bab8517b2a
@ -203,6 +203,10 @@ 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
|
||||||
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
|
return current_charge
|
||||||
|
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.
|
||||||
|
@ -51,6 +51,10 @@ local mining_drill_mode_text = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local function drill_dig_it0 (pos,player)
|
local function drill_dig_it0 (pos,player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
local node=minetest.env:get_node(pos)
|
local node=minetest.env:get_node(pos)
|
||||||
if node.name == "air" or node.name == "ignore" then return end
|
if node.name == "air" or node.name == "ignore" then return end
|
||||||
if node.name == "default:lava_source" then return end
|
if node.name == "default:lava_source" then return end
|
||||||
|
@ -60,6 +60,10 @@ local function node_tab(z, d)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function laser_node(pos, player)
|
local function laser_node(pos, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "air"
|
if node.name == "air"
|
||||||
or node.name == "ignore"
|
or node.name == "ignore"
|
||||||
|
@ -12,12 +12,16 @@ minetest.register_tool("technic:sonic_screwdriver", {
|
|||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing, above)
|
local pos = pointed_thing.under
|
||||||
|
if minetest.is_protected(pos, user:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos, user:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local node_name = node.name
|
local node_name = node.name
|
||||||
if minetest.registered_nodes[node_name].paramtype2 ~= "facedir" and
|
if minetest.registered_nodes[node_name].paramtype2 ~= "facedir" and
|
||||||
minetest.registered_nodes[node_name].paramtype2 ~= "wallmounted" then
|
minetest.registered_nodes[node_name].paramtype2 ~= "wallmounted" then
|
||||||
return itemstack
|
return
|
||||||
end
|
end
|
||||||
if node.param2 == nil then
|
if node.param2 == nil then
|
||||||
return
|
return
|
||||||
|
@ -4,34 +4,35 @@ local S = technic.getter
|
|||||||
minetest.register_tool("technic:treetap", {
|
minetest.register_tool("technic:treetap", {
|
||||||
description = S("Tree Tap"),
|
description = S("Tree Tap"),
|
||||||
inventory_image = "technic_tree_tap.png",
|
inventory_image = "technic_tree_tap.png",
|
||||||
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
|
return
|
||||||
end
|
end
|
||||||
if user:get_inventory():room_for_item("main",ItemStack("technic:raw_latex")) then
|
local inv = user:get_inventory()
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing,above)
|
if not inv:room_for_item("main", ItemStack("technic:raw_latex")) then
|
||||||
local node = minetest.env:get_node(pos)
|
return
|
||||||
|
end
|
||||||
|
local pos = pointed_thing.under
|
||||||
|
if minetest.is_protected(pos, user:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pos, user:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
local node_name = node.name
|
local node_name = node.name
|
||||||
if node_name == "moretrees:rubber_tree_trunk" then
|
if node_name ~= "moretrees:rubber_tree_trunk" then
|
||||||
|
return
|
||||||
|
end
|
||||||
node.name = "moretrees:rubber_tree_trunk_empty"
|
node.name = "moretrees:rubber_tree_trunk_empty"
|
||||||
user:get_inventory():add_item("main", ItemStack("technic:raw_latex"))
|
inv:add_item("main", ItemStack("technic:raw_latex"))
|
||||||
minetest.set_node(pos,node)
|
minetest.swap_node(pos, node)
|
||||||
local item = itemstack:to_table()
|
local item_wear = tonumber(itemstack:get_wear())
|
||||||
local item_wear = tonumber((item["wear"]))
|
|
||||||
item_wear = item_wear + 819
|
item_wear = item_wear + 819
|
||||||
if item_wear > 65535 then
|
if item_wear > 65535 then
|
||||||
itemstack:clear()
|
itemstack:clear()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
item["wear"] = tostring(item_wear)
|
itemstack:set_wear(item_wear)
|
||||||
itemstack:replace(item)
|
|
||||||
return itemstack
|
return itemstack
|
||||||
else
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user