Added basic NodeCore support

Orehud will now show where Lode ore is.

  Xray will make Stone visible.
This commit is contained in:
Apollo 2022-01-01 18:16:53 -05:00
parent 4d73085af4
commit c45fae5ad9
8 changed files with 150 additions and 27 deletions

@ -5,7 +5,7 @@ Combines various tech to allow advanced mining operations.
## What's in the box
* Orehud: The original Oretracker mod with a single command to toggle the mod on or off per individual player.
* Xray: Based on Orehud except trackes non-ores and makes them appear invisible.
* Xray: Based on Orehud except tracks non-ores and makes them appear invisible.
## Orehud
@ -25,3 +25,9 @@ Yes, because xray interacts server side, all clients can make use of a single pl
* It was found that if the server crashes while a player is using xray, xray's nodes are kept. Created a special mode (fix_mode) to attempt to repair nodes which should return back to their original uppon detection. (If fix_mode is left on in production other players xrays can be overriden)
* It is possible to get xray nodes to say simply by logging off, xray attempts to cleanup nodes by players who are attempting to log out. (Please make an issue report with any logs and screenshots/video showing this still occurs)
## Things planned
* Improve Xray and Orehud so the api can litterally add new nodes (so I don't need to release updates for others to add support for their mods/games)
* Possibly add a formspec for Xray so you could customize your xray, per player (i.e. know a node you don't want to see, just add it via the formspec)

@ -20,7 +20,11 @@ orehud.scan_frequency = 3 -- Frequency in seconds
-- This attempts to detect the gamemode
if not minetest.registered_nodes["default:stone"] then
if not minetest.registered_nodes["mcl_core:stone"] then
orehud.gamemode = "N/A"
if minetest.registered_nodes["nc_terrain:stone"] then
orehud.gamemode = "NC"
else
orehud.gamemode = "N/A"
end
else
orehud.gamemode = "MCL"
-- Attempt to determine if it's MCL5 or MCL2
@ -79,6 +83,10 @@ if orehud.gamemode == "MTG" then
orehud.add_ore("default:stone_with_diamond")
end
if orehud.gamemode == "NC" then
orehud.add_ore("nc_lode:ore")
end
local size = 0
local result = "Ores: "
for i, v in ipairs(orehud.ores) do
@ -146,6 +154,9 @@ orehud.check_player = function(player)
elseif string.find(node.name, "glowstone") then
block = "Glo"
color = 0xffff4b
elseif string.find(node.name, "lode") then -- nc_lode:ore
block = "Lode"
color = 0xaf644b
end
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..".")

@ -1,5 +1,4 @@
name = orehud
description = Displays ore positions via the HUD.
author = ApolloX
optional_depends = default, mcl_core, mcl_deepslate, mcl_nether, mcl_nether_gold
optional_depends = default, mcl_core, mcl_deepslate, mcl_nether, mcl_nether_gold, nc_terrain, nc_lode

@ -1,5 +1,5 @@
-- https://rubenwardy.com/minetest_modding_book/en/map/timers.html#active-block-modifiers
-- An ABM seems slow, so this is a great feature for cleaning up those crashs
-- An ABM seems slow, but this is a great feature for cleaning up those crashs
-- MTG
minetest.register_abm({
@ -126,3 +126,13 @@ minetest.register_abm({
minetest.set_node(pos, {name = "mcl_deepslate:deepslate"})
end
})
-- NC
minetest.register_abm({
nodenames = {"xray:nc_stone"},
interval = 1, -- Run every X seconds
action = function(pos, node, active_object_count,
active_object_count_wider)
minetest.set_node(pos, {name = "nc_terrain:stone"})
end
})

@ -19,6 +19,29 @@ xray.add_pos = function(pname, pos)
local nps = xray.store[pname] or {}
table.insert(nps, pos)
-- Place a switch here to identify which kind of node would be best used here
if current == "default:stone" then -- Returns cobble rather than itself!
minetest.swap_node(pos, {name="xray:mtg_stone"})
xray.store[pname] = nps
elseif current == "mcl_core:stone" then -- Returns cobble rather than itself!
minetest.swap_node(pos, {name="xray:mcl_stone"})
xray.store[pname] = nps
else
-- Fix this so we can auto determine what to replace it with
for _, n in ipairs(xray.nodes) do
if string.sub(n, 0, 4) == "xray" then
local nod = ItemStack(n.." 1"):get_definition()
if nod.drop == current then
--minetest.log("action", "[oretracker-xray] Located '"..n.."' for replacement.")
minetest.swap_node(pos, {name=n})
xray.store[pname] = nps
break
else
--minetest.log("action", "[oretracker-xray] '"..n.."' is not our current it's drop is '"..nod.drop.."'.")
end
end
end
end
--[[
if current == "default:stone" then
minetest.swap_node(pos, {name="xray:mtg_stone"})
elseif current == "default:desert_stone" then
@ -49,9 +72,10 @@ xray.add_pos = function(pname, pos)
minetest.swap_node(pos, {name="xray:mcl_netherrack"})
elseif current == "mcl_deepslate:deepslate" then
minetest.swap_node(pos, {name="xray:mcl_deepslate"})
elseif current == "nc_terrain:stone" then
minetest.swap_node(pos, {name="xray:nc_stone"})
end
-- Stone, Diorite, Anasite, Granite, etc.
xray.store[pname] = nps
]]
end
-- Clears all invisible nodes back to their originals (per player)
@ -67,6 +91,25 @@ xray.clear_pos = function(pname)
node = node.name
--minetest.log("action", "[oretracker-xray] Reverting "..current)
-- Place a switch here to identify what node should be put back here
if node == "xray:mtg_stone" then -- Returns cobble rather than itself!
minetest.swap_node(v, {name="default:stone"})
elseif node == "xray:mcl_stone" then -- Returns cobble rather than itself!
minetest.swap_node(v, {name="mcl_core:stone"})
else
-- Fix this so we can auto determine what to replace it with
for _, n in ipairs(xray.nodes) do
if string.sub(n, 0, 4) == "xray" then
local nod = ItemStack(n.." 1"):get_definition()
if n == node then
--minetest.log("action", "[oretracker-xray] Located '"..n.."' for replacement.")
minetest.swap_node(v, {name=nod.drop})
else
--minetest.log("action", "[oretracker-xray] '"..n.."' is not our current it's drop is '"..nod.drop.."'.")
end
end
end
end
--[[
if node == "xray:mtg_stone" then
minetest.swap_node(v, {name="default:stone"})
elseif node == "xray:mtg_dstone" then
@ -97,7 +140,10 @@ xray.clear_pos = function(pname)
minetest.swap_node(v, {name="mcl_nether:netherrack"})
elseif node == "xray:mcl_deepslate" then
minetest.swap_node(v, {name="mcl_deepslate:deepslate"})
elseif node == "xray:nc_stone" then
minetest.swap_node(v, {name="nc_terrain:stone"})
end
]]
end
xray.store[pname] = {}
end
@ -110,6 +156,27 @@ xray.fix_pos = function (pos)
minetest.log("action", "[oretracker-xray] Failed to obtain node at "..minetest.pos_to_string(pos).." for revert (fix_pos)")
end
node = node.name
-- Place a switch here to identify what node should be put back here
if node == "xray:mtg_stone" then -- Returns cobble rather than itself!
minetest.swap_node(v, {name="default:stone"})
elseif node == "xray:mcl_stone" then -- Returns cobble rather than itself!
minetest.swap_node(v, {name="mcl_core:stone"})
else
-- Fix this so we can auto determine what to replace it with
for _, n in ipairs(xray.nodes) do
if string.sub(n, 0, 4) == "xray" then
local nod = ItemStack(n.." 1"):get_definition()
if n == node then
--minetest.log("action", "[oretracker-xray] Located '"..n.."' for replacement.")
minetest.swap_node(pos, {name=nod.drop})
else
--minetest.log("action", "[oretracker-xray] '"..n.."' is not our current it's drop is '"..nod.drop.."'.")
end
end
end
end
--[[
-- Fix this so we can auto determine what to replace it with
if node == "xray:mtg_stone" then
minetest.swap_node(pos, {name="default:stone"})
elseif node == "xray:mtg_dstone" then
@ -140,5 +207,8 @@ xray.fix_pos = function (pos)
minetest.swap_node(pos, {name="mcl_nether:netherrack"})
elseif node == "xray:mcl_deepslate" then
minetest.swap_node(pos, {name="mcl_deepslate:deepslate"})
elseif node == "xray:nc_stone" then
minetest.swap_node(pos, {name="nc_terrain:stone"})
end
]]
end

@ -25,7 +25,11 @@ xray.light_level = 4 -- From 0-14
-- This attempts to detect the gamemode
if not minetest.registered_nodes["default:stone"] then
if not minetest.registered_nodes["mcl_core:stone"] then
xray.gamemode = "N/A"
if not minetest.registered_nodes["nc_terrain:stone"] then
xray.gamemode = "N/A"
else
xray.gamemode = "NC"
end
else
-- Attempt to determine if it's MCL5 or MCL2
if not minetest.registered_nodes["mcl_deepslate:deepslate"] then
@ -76,23 +80,31 @@ if xray.gamemode == "MTG" then
xray.add_node("default:silver_sandstone") -- xray:mtg_ssstone
end
if xray.gamemode == "NC" then
xray.add_node("nc_terrain:stone") -- xray:nc_stone
end
-- Include our nodes so we can cleanup after ourselves
-- Yeah there will be warnings in your logs about unknown nodes but who really checks that anyway.
xray.add_node("xray:mtg_stone")
xray.add_node("xray:mtg_dstone")
xray.add_node("xray:mtg_sstone")
xray.add_node("xray:mtg_dsstone")
xray.add_node("xray:mtg_ssstone")
xray.add_node("xray:mcl_stone")
xray.add_node("xray:mcl_granite")
xray.add_node("xray:mcl_andesite")
xray.add_node("xray:mcl_diorite")
xray.add_node("xray:mcl_sstone")
xray.add_node("xray:mcl_rsstone")
xray.add_node("xray:mcl_bstone")
xray.add_node("xray:mcl_basalt")
xray.add_node("xray:mcl_netherrack")
xray.add_node("xray:mcl_deepslate")
if xray.gamemode == "MTG" then
xray.add_node("xray:mtg_stone")
xray.add_node("xray:mtg_dstone")
xray.add_node("xray:mtg_sstone")
xray.add_node("xray:mtg_dsstone")
xray.add_node("xray:mtg_ssstone")
elseif xray.gamemode == "MCL2" or xray.gamemode == "MCL5" then
xray.add_node("xray:mcl_stone")
xray.add_node("xray:mcl_granite")
xray.add_node("xray:mcl_andesite")
xray.add_node("xray:mcl_diorite")
xray.add_node("xray:mcl_sstone")
xray.add_node("xray:mcl_rsstone")
xray.add_node("xray:mcl_bstone")
xray.add_node("xray:mcl_basalt")
xray.add_node("xray:mcl_netherrack")
xray.add_node("xray:mcl_deepslate")
elseif xray.gamemode == "NC" then
xray.add_node("xray:nc_stone")
end
local size = 0
local result = "Nodes: "
@ -120,9 +132,10 @@ xray.check_player = function(p)
if distance <= xray.detect_range*xray.detect_range then
--distance = string.format("%.0f", math.sqrt(distance))
-- Place the counterpart
--minetest.log("action", "xray "..pname.." "..minetest.pos_to_string(area[1], 1))
if xray.p_stats[pname] then
--minetest.log("action", "xray "..pname.." "..minetest.pos_to_string(area[i], 1).." "..node.name)
if xray.p_stats[pname] ~= nil then
-- Adds the counter since we are enabled
--minetest.log("action", "xray "..pname.." "..minetest.pos_to_string(area[i], 1).." "..node.name)
xray.add_pos(pname, area[i])
end
end

@ -1,4 +1,4 @@
name = xray
description = Hides stone and stone varients from view.
author = ApolloX
optional_depends = default, mcl_core, mcl_sounds, mcl_deepslate, mcl_blackstone, mcl_nether
optional_depends = default, mcl_core, mcl_sounds, mcl_deepslate, mcl_blackstone, mcl_nether, nc_terrain

@ -234,3 +234,17 @@ if xray.gamemode == "MCL5" then
_mcl_silk_touch_drop = false,
})
end
if xray.gamemode == "NC" then
minetest.register_node("xray:nc_stone", {
description = xray.S("Xray Stone"),
tiles = {"xray_stone.png"},
groups = {cracky = 2, stone = 1, rock = 1},
drop = "nc_terrain:stone",
drawtype = "glasslike",
sunlight_propagates = true,
legacy_mineral = true,
light_source = xray.light_level,
sounds = nodecore.sounds("nc_terrain_stony")
})
end