WIP Untested iterating over registered ores

This should work, but I'm not sure how well this will work
This commit is contained in:
Apollo 2024-07-01 23:28:35 -04:00
parent 600dfbc101
commit 7b00d07e28

@ -95,14 +95,17 @@ orehud.add_ores = function ()
end end
end end
local size = 0 minetest.register_on_mods_loaded(function()
local result = "Ores: " orehud.add_ores()
for i, v in ipairs(orehud.ores) do local size = 0
result = result..v.." " local result = "Ores: "
size = size + 1 for i, v in ipairs(orehud.ores) do
end result = result..v.." "
minetest.log("action", "[oretracker-orehud] Found "..size.." ores configured.") size = size + 1
minetest.log("action", "[oretracker-orehud] "..result) end
minetest.log("action", "[oretracker-orehud] Found "..size.." ores configured.")
minetest.log("action", "[oretracker-orehud] "..result)
end)
-- Itterates an area of nodes for "ores", then adds a waypoint at that nodes position for that "ore". -- Itterates an area of nodes for "ores", then adds a waypoint at that nodes position for that "ore".
orehud.check_player = function(player) orehud.check_player = function(player)
@ -126,8 +129,9 @@ orehud.check_player = function(player)
distance = string.format("%.0f", math.sqrt(distance)) distance = string.format("%.0f", math.sqrt(distance))
local block = "?" local block = "?"
local color = 0xffffff local color = 0xffffff
local def = minetest.registered_nodes[node.name] or nil
if string.find(node.name, "coal") then color = 0xc8c84b
--[[if string.find(node.name, "coal") then
block = "Coa" block = "Coa"
color = 0xc8c8c8 color = 0xc8c8c8
elseif string.find(node.name, "iron") then elseif string.find(node.name, "iron") then
@ -167,6 +171,10 @@ orehud.check_player = function(player)
block = "Lode" block = "Lode"
color = 0xaf644b color = 0xaf644b
end end
]]
if def ~= nil then
block = def.short_description or def.description
end
if block == "?" then if block == "?" then
minetest.log("action", "[oretracker-orehud] Found '"..node.name.."' at "..minetest.pos_to_string(area[i], 1).." which is "..distance.." away from '"..pname..".") minetest.log("action", "[oretracker-orehud] Found '"..node.name.."' at "..minetest.pos_to_string(area[i], 1).." which is "..distance.." away from '"..pname..".")
block = node.name block = node.name