Skip to content

Commit e376d57

Browse files
PoikilosSmallJoker
authored andcommitted
Add optional bones messages for player and log
1 parent 37b206e commit e376d57

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

minetest.conf.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
# 0 to disable. By default it is "share_bones_time" divide by four.
2424
#share_bones_time_early = 300
2525

26+
# Inform player of condition and location of new bones.
27+
#bones_position_message = false
28+
2629
# Whether fire should be enabled. If disabled, 'basic_flame' nodes will
2730
# disappear.
2831
# 'permanent_flame' nodes will remain with either setting.

mods/bones/init.lua

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,32 @@ minetest.register_on_dieplayer(function(player)
186186
bones_mode = "bones"
187187
end
188188

189+
local bones_position_message = minetest.settings:get_bool("bones_position_message") == true
190+
local player_name = player:get_player_name()
191+
local pos = vector.round(player:get_pos())
192+
local pos_string = minetest.pos_to_string(pos)
193+
189194
-- return if keep inventory set or in creative mode
190195
if bones_mode == "keep" or (creative and creative.is_enabled_for
191196
and creative.is_enabled_for(player:get_player_name())) then
197+
minetest.log("action", player_name .. " dies at " .. pos_string ..
198+
". No bones placed")
199+
if bones_position_message then
200+
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string .. ".")
201+
end
192202
return
193203
end
194204

195205
local player_inv = player:get_inventory()
196206
if is_all_empty(player_inv) then
207+
minetest.log("action", player_name .. " dies at " .. pos_string ..
208+
". No bones placed")
209+
if bones_position_message then
210+
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string .. ".")
211+
end
197212
return
198213
end
199214

200-
local pos = vector.round(player:getpos())
201-
local player_name = player:get_player_name()
202-
203215
-- check if it's possible to place bones, if not find space near player
204216
if bones_mode == "bones" and not may_replace(pos, player) then
205217
local air = minetest.find_node_near(pos, 1, {"air"})
@@ -218,12 +230,25 @@ minetest.register_on_dieplayer(function(player)
218230
player_inv:set_list(list_name, {})
219231
end
220232
drop(pos, ItemStack("bones:bones"))
233+
minetest.log("action", player_name .. " dies at " .. pos_string ..
234+
". Inventory dropped")
235+
if bones_position_message then
236+
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string ..
237+
", and dropped their inventory.")
238+
end
221239
return
222240
end
223241

224242
local param2 = minetest.dir_to_facedir(player:get_look_dir())
225243
minetest.set_node(pos, {name = "bones:bones", param2 = param2})
226244

245+
minetest.log("action", player_name .. " dies at " .. pos_string ..
246+
". Bones placed")
247+
if bones_position_message then
248+
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string ..
249+
", and bones were placed.")
250+
end
251+
227252
local meta = minetest.get_meta(pos)
228253
local inv = meta:get_inventory()
229254
inv:set_size("main", 8 * 4)

settingtypes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ tnt_radius (TNT radius) int 3 0
4444
# Setting this to 0 will disable sharing of bones completely.
4545
share_bones_time (Bone share time) int 1200 0
4646

47+
# Inform player of condition and location of new bones.
48+
bones_position_message (Inform player about bones) bool false
49+
4750
# Replaces old stairs with new ones. Only required for older worlds.
4851
enable_stairs_replace_abm (Replace old stairs) bool false
4952

0 commit comments

Comments
 (0)