-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
170 lines (147 loc) · 4.17 KB
/
Copy pathinit.lua
File metadata and controls
170 lines (147 loc) · 4.17 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
--init
local S = minetest.get_translator(minetest.get_current_modname())
local glass
local glass_fragment = ""
local glass_break_sound
local glass_tools = {
["glass_tools:pick_glass"] = true,
["glass_tools:axe_glass"] = true,
["glass_tools:shovel_glass"] = true,
["glass_tools:sword_glass"] = true
}
if minetest.get_modpath("default") then
glass = "default:glass"
glass_break_sound = default.node_sound_glass_defaults().dug
elseif minetest.get_modpath("mcl_sounds") then
glass = "mcl_core:glass"
glass_break_sound = mcl_sounds.node_sound_glass_defaults().dug
end
if minetest.get_modpath("vessels") then
glass_fragment = "vessels:glass_fragments"
end
local function glass_tool_break(player)
if player and player:is_player() then
local player_name = player:get_player_name()
if glass_break_sound then
minetest.sound_play(glass_break_sound.name, {to_player = player_name, gain = glass_break_sound.gain or 1.0})
end
if 1 == math.random(1, 4) then
player:set_hp(player:get_hp() - math.random(1, 3))
return glass_fragment .. " 1"
end
return ""
end
return ""
end
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack and glass_tools[itemstack:get_name()] then
if player and player:is_player() then
if 1 == math.random(1, 8) then
local player_name = player:get_player_name()
if glass_break_sound then
minetest.sound_play(glass_break_sound.name, {to_player = player_name, gain = glass_break_sound.gain or 1.0})
end
player:set_hp(player:get_hp() - math.random(1, 2))
return glass_fragment .. " " .. math.random(1, 2)
end
end
end
end)
minetest.register_tool("glass_tools:pick_glass", {
description = S("Glass Pickaxe"),
inventory_image = "glass_tools_pick.png",
tool_capabilities = {
full_punch_interval = 1.2,
max_drop_level = 0,
groupcaps = {},
damage_groups = {fleshy = 4},
},
groups = {pickaxe = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing and pointed_thing.type ~= "nothing" then
return glass_tool_break(user)
end
end
})
minetest.register_tool("glass_tools:axe_glass", {
description = S("Glass Axe"),
inventory_image = "glass_tools_axe.png",
tool_capabilities = {
full_punch_interval = 1,
max_drop_level = 0,
groupcaps = {},
damage_groups = {fleshy = 3},
},
groups = {axe = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing and pointed_thing.type ~= "nothing" then
return glass_tool_break(user)
end
end
})
minetest.register_tool("glass_tools:shovel_glass", {
description = S("Glass Shovel"),
inventory_image = "glass_tools_shovel.png^[transformR90",
tool_capabilities = {
full_punch_interval = 1.2,
max_drop_level = 0,
groupcaps = {},
damage_groups = {fleshy = 3},
},
groups = {shovel = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing and pointed_thing.type ~= "nothing" then
return glass_tool_break(user)
end
end
})
minetest.register_tool("glass_tools:sword_glass", {
description = S("Glass Sword"),
inventory_image = "glass_tools_sword.png",
tool_capabilities = {
full_punch_interval = 1.2,
max_drop_level = 0,
groupcaps = {},
damage_groups = {fleshy = 5},
},
groups = {sword = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing and pointed_thing.type ~= "nothing" then
return glass_tool_break(user)
end
end
})
if glass then
minetest.register_craft({
output = "glass_tools:pick_glass 1",
recipe = {
{glass, glass, glass},
{"", "group:stick", ""},
{"", "group:stick", ""}
}
})
minetest.register_craft({
output = "glass_tools:axe_glass 1",
recipe = {
{glass, glass, ""},
{glass, "group:stick", ""},
{"", "group:stick", ""}
}
})
minetest.register_craft({
output = "glass_tools:shovel_glass 1",
recipe = {
{"", glass, ""},
{"", "group:stick", ""},
{"", "group:stick", ""}
}
})
minetest.register_craft({
output = "glass_tools:sword_glass 1",
recipe = {
{"", glass, ""},
{"", glass, ""},
{"", "group:stick", ""}
}
})
end