aboutsummaryrefslogtreecommitdiff
path: root/init.lua
blob: addadab1a95780190c0d1056f85a8c5914d2f955 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--[[
Copyright © 2012-2020 Hugo Locurcio and contributors.
Copyright © 2024 Runxi Yu
Licensed under the zlib license. See LICENSE.md for more information.
--]]

rxmin = {}

local modpath = minetest.get_modpath("rxmin")

local S = minetest.get_translator("rxmin")

rxmin.drop_msg = function(itemstack, player)
	local name = player:get_player_name()
	minetest.chat_send_player(name, S("[rxmin] tools/nodes do not drop!"))
end

local pick_admin_toolcaps = {
	full_punch_interval = 0.1,
	max_drop_level = 3,
	groupcaps = {
		unbreakable = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		fleshy = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		choppy = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		bendy = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		cracky = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		crumbly = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
		snappy = {times = {[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 5},
	},
	damage_groups = {fleshy = 1000},
}

minetest.register_tool("rxmin:pick_admin", {
	description = S("Admin Pickaxe"),
	range = 20,
	inventory_image = "rxmin_adminpick.png",
	groups = {not_in_creative_inventory = 0},
	tool_capabilities = pick_admin_toolcaps,
	on_drop = rxmin.drop_msg,
})

minetest.register_tool("rxmin:pick_admin_with_drops", {
	description = S("Admin Pickaxe with Drops"),
	range = 20,
	inventory_image = "rxmin_adminpick_with_drops.png",
	groups = {not_in_creative_inventory = 0},
	tool_capabilities = pick_admin_toolcaps,
	on_drop = rxmin.drop_msg,
})

minetest.register_on_punchnode(function(pos, node, puncher)
	if puncher:get_wielded_item():get_name() == "rxmin:pick_admin"
	and minetest.get_node(pos).name ~= "air" then
		minetest.log(
			"action",
			puncher:get_player_name() ..
			" digs " ..
			minetest.get_node(pos).name ..
			" at " ..
			minetest.pos_to_string(pos) ..
			" using an Admin Pickaxe."
		)
		-- The node is removed directly, which means it even works
		-- on non-empty containers and group-less nodes
		minetest.remove_node(pos)
		-- Run node update actions like falling nodes
		minetest.check_for_falling(pos)
	end
end)

minetest.register_alias("adminpick", "rxmin:pick_admin")
minetest.register_alias("adminpickdrops", "rxmin:pick_admin_with_drops")

function node_sound_stone_defaults(tbl)
	tbl = tbl or {}
	tbl.footstep = tbl.footstep or
			{name = "default_hard_footstep", gain = 0.2}
	tbl.dug = tbl.dug or
			{name = "default_hard_footstep", gain = 1.0}
	tbl.place = tbl.place or
			{name = "default_place_node_hard", gain = 1.0}
	return tbl
end

minetest.register_node(":default:mese", {
	description = S("Mese Block"),
	tiles = {"default_mese_block.png"},
	paramtype = "light",
	groups = {cracky = 1, level = 2},
	sounds = node_sound_stone_defaults(),
	light_source = 3,
})
minetest.register_alias("mesecons_gamecompat:mese", "default:mese")