From cf2786a81870f6b398e73a8ea949dc43e888e84b Mon Sep 17 00:00:00 2001 From: stujones11 Date: Tue, 8 Apr 2014 22:03:01 +0100 Subject: [PATCH] Add support for bones mod --- 3d_armor/armor.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/3d_armor/armor.lua b/3d_armor/armor.lua index 6c35686..f382ed9 100644 --- a/3d_armor/armor.lua +++ b/3d_armor/armor.lua @@ -248,6 +248,41 @@ minetest.register_on_joinplayer(function(player) end, player) end) +if minetest.get_modpath("bones") then + minetest.register_on_dieplayer(function(player) + local name = player:get_player_name() + local pos = player:getpos() + if name and pos then + pos = vector.round(pos) + local drop = {} + local player_inv = player:get_inventory() + local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"}) + for _,v in ipairs(armor.elements) do + local list = "armor_"..v + table.insert(drop, player_inv:get_stack(list, 1)) + armor_inv:set_stack(list, 1, nil) + player_inv:set_stack(list, 1, nil) + end + armor:set_player_armor(player) + minetest.after(1, function() --TODO: Make delay configurable + local node = minetest.get_node(pos) + if node.name == "bones:bones" then + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local inv = meta:get_inventory() + if name == owner then + for _,list in ipairs(drop) do + if inv:room_for_item("main", list) then + inv:add_item("main", list) + end + end + end + end + end) + end + end) +end + minetest.register_globalstep(function(dtime) time = time + dtime if time > update_time then