techage_modpack_ru_upd/techage/tools/trowel.lua

69 lines
1.7 KiB
Lua
Raw Permalink Normal View History

2020-05-31 23:31:18 +03:00
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
2020-10-25 23:32:47 +03:00
AGPL v3
2020-05-31 23:31:18 +03:00
See LICENSE.txt for more information
2022-01-04 21:43:30 +03:00
2020-05-31 23:31:18 +03:00
Trowel tool to hide/open cable/pipe/tube nodes
]]--
-- for lazy programmers
local P = minetest.string_to_pos
local M = minetest.get_meta
local S = techage.S
local function replace_node(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.under
2020-10-25 23:32:47 +03:00
local name = placer:get_player_name()
if minetest.is_protected(pos, name) then
return
end
2021-08-01 12:00:22 +03:00
local node = minetest.get_node(pos)
local res = false
2020-05-31 23:31:18 +03:00
if minetest.get_item_group(node.name, "techage_trowel") == 1 then
2021-08-01 12:00:22 +03:00
res = networks.hide_node(pos, node, placer)
elseif networks.hidden_name(pos) or M(pos):get_string("techage_hidden_nodename") ~= "" then
res = networks.open_node(pos, node, placer)
else
minetest.chat_send_player(placer:get_player_name(), "Invalid/unsuported block!")
return
end
if res then
minetest.sound_play("default_dig_snappy", {
2022-01-04 21:43:30 +03:00
pos = pos,
2021-08-01 12:00:22 +03:00
gain = 1,
max_hear_distance = 5})
elseif placer and placer.get_player_name then
minetest.chat_send_player(placer:get_player_name(), "Invalid fill material in inventory slot 1!")
2020-05-31 23:31:18 +03:00
end
end
end
minetest.register_tool("techage:trowel", {
description = S("TechAge Trowel"),
inventory_image = "techage_trowel.png",
wield_image = "techage_trowel.png",
2021-05-14 19:50:16 +03:00
use_texture_alpha = techage.CLIP,
2020-05-31 23:31:18 +03:00
groups = {cracky=1},
on_use = replace_node,
on_place = replace_node,
node_placement_prediction = "",
stack_max = 1,
})
minetest.register_craft({
output = "techage:trowel",
recipe = {
{"basic_materials:steel_bar", "basic_materials:steel_bar", ""},
{"basic_materials:steel_bar", "default:stick", ""},
{"", "", "default:stick"},
},
})