@@ -4,11 +4,6 @@ headnumber = 129
4
4
5
5
for i = 1 , headnumber do
6
6
7
- local x = i + 1
8
- local y = i - 1
9
- if x > headnumber then x = 1 end
10
- if y < 1 then y = headnumber end
11
-
12
7
minetest .register_node (" heads:head_" .. i , {
13
8
description = " Head Number " .. i ,
14
9
wield_scale = {x = 1.5 , y = 1.5 , z = 1.5 },
@@ -37,8 +32,9 @@ for i = 1, headnumber do
37
32
fixed = { - 0.25 , - 0.5 , - 0.25 , 0.25 , 0.0 , 0.25 , },
38
33
},
39
34
groups = {snappy = 1 ,choppy = 2 ,oddly_breakable_by_hand = 2 ,flammable = 3 },
40
- drop = " heads:head_" .. i ,
41
-
35
+ sounds = default .node_sound_wood_defaults (),
36
+ drop = " " ,
37
+ stack_max = 1 ,
42
38
after_place_node = function (pos , placer , itemstack )
43
39
44
40
local item = placer :get_wielded_item ():to_string ()
@@ -53,33 +49,64 @@ for i = 1, headnumber do
53
49
54
50
after_dig_node = function (pos , oldnode , oldmetadata , digger )
55
51
52
+ if not digger then return end
53
+
56
54
local meta = minetest .get_meta (pos )
55
+ meta :from_table (oldmetadata )
57
56
local description = meta :get_string (" description" )
58
57
59
58
local stack = ItemStack (oldnode .name )
60
59
local meta2 = stack :get_meta ()
61
60
meta2 :set_string (" description" , description )
62
-
63
- minetest .add_item ({x = pos .x , y = pos .y + 1 , z = pos .z }, stack )
64
-
61
+
62
+ if digger :get_inventory ():room_for_item (" main" , stack ) then
63
+ digger :get_inventory ():add_item (' main' , stack )
64
+ else
65
+ minetest .add_item ({x = pos .x , y = pos .y + 1 , z = pos .z }, stack )
66
+ end
67
+
65
68
end ,
66
69
67
70
})
68
71
69
72
end
70
73
71
74
72
- minetest .register_on_dieplayer (function (player )
73
-
74
- local name = player :get_player_name ()
75
+ minetest .register_on_punchplayer (function (player , hitter , _ , _ , _ , damage )
76
+ if not (hitter and hitter :is_player ()) then
77
+ return
78
+ end
79
+
80
+ local hp = player :get_hp ()
81
+ if hp - damage > 0 or hp <= 0 then
82
+ return
83
+ end
84
+
85
+ local hitter_name = hitter :get_player_name ()
86
+ local player_name = player :get_player_name ()
87
+
88
+ local item = hitter :get_wielded_item ():to_string ()
89
+
90
+ local name = player_name
91
+
75
92
local pos = vector .round (player :getpos ())
76
93
local skin_num = string.match (skins .skins [name ]," %d+" )
77
94
78
95
local stack = ItemStack (" heads:head_" .. skin_num )
79
96
local meta = stack :get_meta ()
80
- meta :set_string (" description" , " Head of " .. name )
81
-
82
- minetest .sound_play (" head_drop" , {pos , gain = 1.0 , })
83
- minetest .add_item ({x = pos .x , y = pos .y + 1 , z = pos .z }, stack )
84
-
85
- end )
97
+
98
+ local rand
99
+
100
+ rand = math.random (1 ,100 )
101
+
102
+ if string.match (item , " sword" ) and rand < 20 then
103
+ -- minetest.chat_send_all("*** Server: "..hitter_name.." killed " .. player_name ..""..item)
104
+
105
+ meta :set_string (" description" , " Head of " .. name )
106
+ minetest .sound_play (" head_drop" , {pos , gain = 1.0 , })
107
+ minetest .add_item ({x = pos .x , y = pos .y + 1 , z = pos .z }, stack )
108
+
109
+ end
110
+
111
+
112
+ end )
0 commit comments