@@ -119,9 +119,72 @@ minetest.override_item("default:apple", {
119
119
end
120
120
end ,
121
121
after_place_node = nil ,
122
- stack_max = 60 ,
123
- on_place = function ()
124
- return nil
122
+ stack_max = 60 ,
123
+ on_place = function () return nil end ,
124
+ on_secondary_use = function (itemstack , placer , pointed )
125
+ if placer == nil then return nil end
126
+ if pointed .type == " node" then return nil end
127
+ if pointed == nil then return pointed end -- :D
128
+ local object = pointed .ref
129
+ if not object :is_player () then return nil end
130
+ local uname = placer :get_player_name ()
131
+ local pname = object :get_player_name ()
132
+ if pname == uname then return nil end
133
+ if ctf_teams .get (pname ) ~= ctf_teams .get (uname ) then
134
+ hud_events .new (uname , {
135
+ quick = true ,
136
+ text = pname .. " isn't in your team!" ,
137
+ color = " warning" ,
138
+ })
139
+ return
140
+ end
141
+
142
+ local hp = object :get_hp ()
143
+ local limit = object :get_properties ().hp_max -- heal to limit
144
+
145
+ if hp <= 0 then
146
+ hud_events .new (uname , {
147
+ quick = true ,
148
+ text = pname .. " is dead!" ,
149
+ color = " warning" ,
150
+ })
151
+ return
152
+ end
153
+ if hp >= limit then
154
+ hud_events .new (uname , {
155
+ quick = true ,
156
+ text = pname .. " already has " .. limit .. " HP!" ,
157
+ color = " warning" ,
158
+ })
159
+ return
160
+ end
161
+ local hp_add = 1
162
+
163
+
164
+ if hp + hp_add > limit then
165
+ hp_add = limit - hp
166
+ hp = limit
167
+ else
168
+ hp = hp + hp_add
169
+ end
170
+
171
+ local result = RunCallbacks (ctf_healing .registered_on_heal , placer , object , hp_add )
172
+
173
+ if not result then
174
+ object :set_hp (hp )
175
+ hud_events .new (pname , {
176
+ quick = true ,
177
+ text = uname .. " healed you!" ,
178
+ color = 0xC1FF44 ,
179
+ })
180
+ elseif type (result ) == " string" then
181
+ hud_events .new (uname , {
182
+ quick = true ,
183
+ text = result ,
184
+ color = " warning" ,
185
+ })
186
+ end
187
+ -- and just dont rightclick flags :D
125
188
end
126
189
})
127
190
0 commit comments