summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-09-01 12:35:03 +0200
committerWuzzy <almikes@aol.com>2016-09-01 12:35:03 +0200
commitbbefabecfb8ee571edce4bd9a821ad021a888f82 (patch)
treeb16ebebef3635c721694c9ca67e6cef9a4748828
parentf7d9bde05da40a36aee190989e0eb68ad2938738 (diff)
Reveal items by dig, punch, place, craft
-rw-r--r--init.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index fd70004..de97589 100644
--- a/init.lua
+++ b/init.lua
@@ -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)