58 lines
1.8 KiB
Lua
58 lines
1.8 KiB
Lua
|
local doc_identifier = {}
|
||
|
doc_identifier.huds = {}
|
||
|
doc_identifier.countdown_ids = {}
|
||
|
|
||
|
doc_identifier.place = function(itemstack, user, pointed_thing)
|
||
|
local username = user:get_player_name()
|
||
|
if pointed_thing.type == "node" then
|
||
|
local pos = pointed_thing.under
|
||
|
local node = minetest.get_node(pos)
|
||
|
if minetest.registered_nodes[node.name] ~= nil then
|
||
|
local nodedef = minetest.registered_nodes[node.name]
|
||
|
if(node.name == "ignore") then
|
||
|
return itemstack
|
||
|
end
|
||
|
if doc.entry_exists("nodes", node.name) then
|
||
|
doc.show_entry(username, "nodes", node.name)
|
||
|
else
|
||
|
minetest.show_formspec(
|
||
|
username,
|
||
|
"doc_identifier:error_missing_node_info",
|
||
|
"size[12,2;]label[0,0.2;The identifier was unable to extract information from this block.]button_exit[4.5,1.5;3,1;okay;OK]"
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
return itemstack
|
||
|
end
|
||
|
|
||
|
return itemstack
|
||
|
end
|
||
|
|
||
|
|
||
|
minetest.register_tool("doc_identifier:identifier_solid", {
|
||
|
description = "block identifier",
|
||
|
tool_capabilities = {},
|
||
|
wield_image = "doc_identifier_identifier.png",
|
||
|
inventory_image = "doc_identifier_identifier.png",
|
||
|
liquids_pointable = false,
|
||
|
on_place = doc_identifier.place,
|
||
|
on_use = function(itemstack, user, pointed_thing)
|
||
|
return ItemStack("doc_identifier:identifier_liquid")
|
||
|
end,
|
||
|
})
|
||
|
minetest.register_tool("doc_identifier:identifier_liquid", {
|
||
|
description = "block identifier",
|
||
|
tool_capabilities = {},
|
||
|
groups = { not_in_creative_inventory = 1 },
|
||
|
wield_image = "doc_identifier_identifier_liquid.png",
|
||
|
inventory_image = "doc_identifier_identifier_liquid.png",
|
||
|
liquids_pointable = true,
|
||
|
on_place = doc_identifier.place,
|
||
|
on_use = function(itemstack, user, pointed_thing)
|
||
|
return ItemStack("doc_identifier:identifier_solid")
|
||
|
end,
|
||
|
})
|
||
|
|
||
|
minetest.register_alias("doc_identifier:identifier", "doc_identifier:identifier_solid")
|