diff options
author | Wuzzy <almikes@aol.com> | 2016-09-01 12:35:03 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-09-01 12:35:03 +0200 |
commit | bbefabecfb8ee571edce4bd9a821ad021a888f82 (patch) | |
tree | b16ebebef3635c721694c9ca67e6cef9a4748828 | |
parent | f7d9bde05da40a36aee190989e0eb68ad2938738 (diff) |
Reveal items by dig, punch, place, craft
-rw-r--r-- | init.lua | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -960,4 +960,37 @@ local function gather_descs() add_entries(minetest.registered_craftitems, "craftitems") end +local function reveal_item(playername, itemstring) + local category_id + if minetest.registered_nodes[itemstring] ~= nil then + category_id = "nodes" + elseif minetest.registered_tools[itemstring] ~= nil then + category_id = "tools" + elseif minetest.registered_craftitems[itemstring] ~= nil then + category_id = "craftitems" + elseif minetest.registered_items[itemstring] ~= nil then + category_id = "craftiems" + else + return false + end + doc.mark_entry_as_revealed(playername, category_id, itemstring) + return true +end + +minetest.register_on_dignode(function(pos, oldnode, digger) + reveal_item(digger:get_player_name(), oldnode.name) +end) + +minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) + reveal_item(puncher:get_player_name(), node.name) +end) + +minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) + reveal_item(player:get_player_name(), itemstack:get_name()) +end) + +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) + reveal_item(placer:get_player_name(), itemstack:get_name()) +end) + minetest.after(0, gather_descs) |