From 3e9eb08c2426c75ab0f3d1c95de6df156827e4c2 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:45:09 -0500 Subject: [PATCH 01/19] Update radiation.lua Api added with the help of Copilot AI. --- technic/radiation.lua | 103 +++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 31 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 7092b697..8aad85c7 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -28,9 +28,26 @@ or complex internal structure should show no radiation resistance. Fractional resistance values are permitted. --]] +local rad_resistance_node = {} +local rad_resistance_group = {} +local cache_radiation_resistance = {} + +-- Function to register node-specific resistance +function technic.register_rad_resistance(node_name, resistance) + rad_resistance_node[node_name] = resistance + cache_radiation_resistance[node_name] = nil -- Invalidate cache +end + +-- Function to register multiple node resistances at once +function technic.register_multiple_resistances(resistances) + for node_name, resistance in pairs(resistances) do + technic.register_rad_resistance(node_name, resistance) + end +end + local S = technic.getter -local rad_resistance_node = { +local node_resistances = { ["default:brick"] = 13, ["default:bronzeblock"] = 45, ["default:clay"] = 15, @@ -165,38 +182,62 @@ local rad_resistance_node = { ["tnt:tnt"] = 11, ["tnt:tnt_burning"] = 11, } -local rad_resistance_group = { - concrete = 16, - tree = 3.4, - uranium_block = 500, - wood = 1.7, -} -local cache_radiation_resistance = {} -local function node_radiation_resistance(node_name) - local resistance = cache_radiation_resistance[node_name] - if resistance then - return resistance - end - local def = minetest.registered_nodes[node_name] - if not def then - cache_radiation_resistance[node_name] = 0 - return 0 - end - resistance = def.radiation_resistance or - rad_resistance_node[node_name] - if not resistance then - resistance = 0 - for g, v in pairs(def.groups) do - if v > 0 and rad_resistance_group[g] then - resistance = resistance + rad_resistance_group[g] - end - end - end - resistance = math.sqrt(resistance) - cache_radiation_resistance[node_name] = resistance - return resistance + +-- Register all node resistances at once +technic.register_multiple_resistances(node_resistances) + +-- Function to register group-specific resistance +function technic.register_group_resistance(group_name, resistance) + rad_resistance_group[group_name] = resistance + -- Invalidate cache for all nodes in this group + for node_name, def in pairs(minetest.registered_nodes) do + if def.groups[group_name] then + cache_radiation_resistance[node_name] = nil + end + end end +technic.register_group_resistance("concrete", 16) +technic.register_group_resistance("tree", 3.4) +technic.register_group_resistance("uranium_block", 500) +technic.register_group_resistance("wood", 1.7) + +-- Function to calculate radiation resistance +function node_radiation_resistance(node_name) + local resistance = cache_radiation_resistance[node_name] + if resistance then + return resistance + end + local def = minetest.registered_nodes[node_name] + if not def then + cache_radiation_resistance[node_name] = 0 + return 0 + end + + -- Check for rad_resistance group in node definition + resistance = 0 + for g, v in pairs(def.groups) do + if g == "rad_resistance" then + resistance = resistance + v + end + end + + -- If no rad_resistance group, use registered node-specific resistance + if resistance == 0 then + resistance = rad_resistance_node[node_name] or 0 + end + + -- Add group-specific resistance if applicable + for g, v in pairs(def.groups) do + if v > 0 and rad_resistance_group[g] then + resistance = resistance + rad_resistance_group[g] + end + end + + resistance = math.sqrt(resistance) + cache_radiation_resistance[node_name] = resistance + return resistance +end --[[ Radioactive nodes cause damage to nearby players. The damage From b9de49b1f89b8bb63782f62c022747d33cd30a07 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:03:57 -0500 Subject: [PATCH 02/19] Update nodes.lua "rad_resistance" group added to lead block node definitions. Playtesting required. --- technic_worldgen/nodes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic_worldgen/nodes.lua b/technic_worldgen/nodes.lua index 90888e43..d7c1bab0 100644 --- a/technic_worldgen/nodes.lua +++ b/technic_worldgen/nodes.lua @@ -106,7 +106,7 @@ minetest.register_node(":technic:lead_block", { description = S("Lead Block"), tiles = { "technic_lead_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=80}, sounds = default.node_sound_stone_defaults() }) From 174ba17d6965ae32e56565076a7cd21f6813002b Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:06:05 -0500 Subject: [PATCH 03/19] Update radiation.lua Lead block removed from node_resistances table. --- technic/radiation.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 8aad85c7..3e38e864 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -171,7 +171,6 @@ local node_resistances = { ["technic:corium_flowing"] = 40, ["technic:corium_source"] = 80, ["technic:granite"] = 18, - ["technic:lead_block"] = 80, ["technic:marble"] = 18, ["technic:marble_bricks"] = 18, ["technic:mineral_chromium"] = 19, From 268d7bc22aef30ce4f100838246d375c7fdc00c1 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sun, 13 Oct 2024 19:48:19 -0500 Subject: [PATCH 04/19] Update radiation.lua Greater than or equal to 0 because negative makes no sense. --- technic/radiation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 3e38e864..f712bc0b 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -222,7 +222,7 @@ function node_radiation_resistance(node_name) end -- If no rad_resistance group, use registered node-specific resistance - if resistance == 0 then + if resistance >= 0 then resistance = rad_resistance_node[node_name] or 0 end From 930efcc51cd294a8c1b935b501b1212246fcfdf5 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:57:02 -0500 Subject: [PATCH 05/19] Update api.md The technic.register_rad_resistance function added --- technic/doc/api.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/technic/doc/api.md b/technic/doc/api.md index c8d22d32..7116f0ab 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -145,6 +145,10 @@ Unsorted functions: * Some configuration function * `technic.tube_inject_item(pos, start_pos, velocity, item)` * Same as `pipeworks.tube_inject_item` +* `technic.register_rad_resistance(node_name, resistance)` + * Sets the radiation resistance of the given node. + * `node_name`: name of the node + * `resistance`: number, radiation resistance of the node ### Energy modifiers * `technic.set_RE_wear(itemstack, item_load, max_charge)` @@ -193,6 +197,9 @@ Groups: * UNRELIABLE. Indicates whether the item or node belongs to technic * `connect_sides = {"top", "left", ...}` * Extends the Minetest API. Indicates where the machine can be connected. +* `radioactive = ` + * Makes the node radioactive. + * ``: Strength of the node's radiation (ex. `80`). Additional definition fields: From cedccb4401c555537e02e48f85270fb84cb5b233 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:05:10 -0500 Subject: [PATCH 06/19] Update radiation.lua Unnecessary function removed. --- technic/radiation.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index f712bc0b..93d07c79 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -38,13 +38,6 @@ function technic.register_rad_resistance(node_name, resistance) cache_radiation_resistance[node_name] = nil -- Invalidate cache end --- Function to register multiple node resistances at once -function technic.register_multiple_resistances(resistances) - for node_name, resistance in pairs(resistances) do - technic.register_rad_resistance(node_name, resistance) - end -end - local S = technic.getter local node_resistances = { @@ -183,7 +176,9 @@ local node_resistances = { } -- Register all node resistances at once -technic.register_multiple_resistances(node_resistances) +for node_name, resistance in pairs(node_resistances) do + technic.register_rad_resistance(node_name, resistance) +end -- Function to register group-specific resistance function technic.register_group_resistance(group_name, resistance) From 2309259f6403ba0d4581372d95790f1458c8b96c Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:16:14 -0500 Subject: [PATCH 07/19] Update radiation.lua Spaces bothered me. --- technic/radiation.lua | 86 +++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 93d07c79..bae580ad 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -34,8 +34,8 @@ local cache_radiation_resistance = {} -- Function to register node-specific resistance function technic.register_rad_resistance(node_name, resistance) - rad_resistance_node[node_name] = resistance - cache_radiation_resistance[node_name] = nil -- Invalidate cache + rad_resistance_node[node_name] = resistance + cache_radiation_resistance[node_name] = nil -- Invalidate cache end local S = technic.getter @@ -177,18 +177,18 @@ local node_resistances = { -- Register all node resistances at once for node_name, resistance in pairs(node_resistances) do - technic.register_rad_resistance(node_name, resistance) + technic.register_rad_resistance(node_name, resistance) end -- Function to register group-specific resistance function technic.register_group_resistance(group_name, resistance) - rad_resistance_group[group_name] = resistance - -- Invalidate cache for all nodes in this group - for node_name, def in pairs(minetest.registered_nodes) do - if def.groups[group_name] then - cache_radiation_resistance[node_name] = nil - end - end + rad_resistance_group[group_name] = resistance + -- Invalidate cache for all nodes in this group + for node_name, def in pairs(minetest.registered_nodes) do + if def.groups[group_name] then + cache_radiation_resistance[node_name] = nil + end + end end technic.register_group_resistance("concrete", 16) @@ -198,39 +198,39 @@ technic.register_group_resistance("wood", 1.7) -- Function to calculate radiation resistance function node_radiation_resistance(node_name) - local resistance = cache_radiation_resistance[node_name] - if resistance then - return resistance - end - local def = minetest.registered_nodes[node_name] - if not def then - cache_radiation_resistance[node_name] = 0 - return 0 - end - - -- Check for rad_resistance group in node definition - resistance = 0 - for g, v in pairs(def.groups) do - if g == "rad_resistance" then - resistance = resistance + v - end - end - - -- If no rad_resistance group, use registered node-specific resistance - if resistance >= 0 then - resistance = rad_resistance_node[node_name] or 0 - end - - -- Add group-specific resistance if applicable - for g, v in pairs(def.groups) do - if v > 0 and rad_resistance_group[g] then - resistance = resistance + rad_resistance_group[g] - end - end - - resistance = math.sqrt(resistance) - cache_radiation_resistance[node_name] = resistance - return resistance + local resistance = cache_radiation_resistance[node_name] + if resistance then + return resistance + end + local def = minetest.registered_nodes[node_name] + if not def then + cache_radiation_resistance[node_name] = 0 + return 0 + end + + -- Check for rad_resistance group in node definition + resistance = 0 + for g, v in pairs(def.groups) do + if g == "rad_resistance" then + resistance = resistance + v + end + end + + -- If no rad_resistance group, use registered node-specific resistance + if resistance >= 0 then + resistance = rad_resistance_node[node_name] or 0 + end + + -- Add group-specific resistance if applicable + for g, v in pairs(def.groups) do + if v > 0 and rad_resistance_group[g] then + resistance = resistance + rad_resistance_group[g] + end + end + + resistance = math.sqrt(resistance) + cache_radiation_resistance[node_name] = resistance + return resistance end --[[ From 11f982acd67ac45b0ade92fedfa90aa90394052e Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:17:33 -0500 Subject: [PATCH 08/19] Update radiation.lua The node_radiation_resistance function is only used locally. --- technic/radiation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index bae580ad..2dc1a307 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -197,7 +197,7 @@ technic.register_group_resistance("uranium_block", 500) technic.register_group_resistance("wood", 1.7) -- Function to calculate radiation resistance -function node_radiation_resistance(node_name) +local function node_radiation_resistance(node_name) local resistance = cache_radiation_resistance[node_name] if resistance then return resistance From 0cf8159a1480bb817f44b7f5c34463be6afeafbd Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:33:30 -0500 Subject: [PATCH 09/19] Update api.md Documented rad_resistance group. --- technic/doc/api.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/technic/doc/api.md b/technic/doc/api.md index 7116f0ab..1c731ee3 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -199,7 +199,10 @@ Groups: * Extends the Minetest API. Indicates where the machine can be connected. * `radioactive = ` * Makes the node radioactive. - * ``: Strength of the node's radiation (ex. `80`). + * ``: Strength of the node's radiation (ex. `2`). +* `rad_resistance = ` + * Makes the node resistant to radiation. + * ``: Strength of the node's resistance (ex. `80`). Additional definition fields: From a9e135118107fc826ab4f444e14d09809d1b818e Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Thu, 17 Oct 2024 00:52:07 -0500 Subject: [PATCH 10/19] Update radiation.lua I guess we only need the rad_resistance group? --- technic/radiation.lua | 56 ++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 2dc1a307..6a3b680a 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -28,14 +28,15 @@ or complex internal structure should show no radiation resistance. Fractional resistance values are permitted. --]] -local rad_resistance_node = {} -local rad_resistance_group = {} -local cache_radiation_resistance = {} - -- Function to register node-specific resistance function technic.register_rad_resistance(node_name, resistance) - rad_resistance_node[node_name] = resistance - cache_radiation_resistance[node_name] = nil -- Invalidate cache + local node = minetest.registered_nodes[node_name] + if node then + if not node.groups then + node.groups = {} + end + node.groups.rad_resistance = resistance + end end local S = technic.getter @@ -182,11 +183,11 @@ end -- Function to register group-specific resistance function technic.register_group_resistance(group_name, resistance) - rad_resistance_group[group_name] = resistance - -- Invalidate cache for all nodes in this group - for node_name, def in pairs(minetest.registered_nodes) do - if def.groups[group_name] then - cache_radiation_resistance[node_name] = nil + for node_name, node_def in pairs(minetest.registered_nodes) do + if node_def.groups[group_name] then + if not node_def.groups.rad_resistance then + node_def.groups.rad_resistance = resistance + end end end end @@ -198,39 +199,18 @@ technic.register_group_resistance("wood", 1.7) -- Function to calculate radiation resistance local function node_radiation_resistance(node_name) - local resistance = cache_radiation_resistance[node_name] - if resistance then - return resistance - end local def = minetest.registered_nodes[node_name] if not def then - cache_radiation_resistance[node_name] = 0 return 0 end - - -- Check for rad_resistance group in node definition - resistance = 0 - for g, v in pairs(def.groups) do - if g == "rad_resistance" then - resistance = resistance + v - end - end - -- If no rad_resistance group, use registered node-specific resistance - if resistance >= 0 then - resistance = rad_resistance_node[node_name] or 0 + local resistance = 0 + -- Add rad_resistance group value if it exists + if def.groups.rad_resistance then + resistance = resistance + def.groups.rad_resistance end - - -- Add group-specific resistance if applicable - for g, v in pairs(def.groups) do - if v > 0 and rad_resistance_group[g] then - resistance = resistance + rad_resistance_group[g] - end - end - - resistance = math.sqrt(resistance) - cache_radiation_resistance[node_name] = resistance - return resistance + + return math.sqrt(resistance) end --[[ From 9eb7d0e7843f27cc9ddc818503fc8a0e32be150f Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Fri, 18 Oct 2024 05:40:45 -0500 Subject: [PATCH 11/19] Update radiation.lua Space caused an error for some reason? --- technic/radiation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 6a3b680a..d7ab44a6 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -209,7 +209,7 @@ local function node_radiation_resistance(node_name) if def.groups.rad_resistance then resistance = resistance + def.groups.rad_resistance end - + return math.sqrt(resistance) end From 8ad1f58cd317c192bdf96370ae39b7681d6b024c Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 19 Oct 2024 02:46:10 -0500 Subject: [PATCH 12/19] Update api.md Documented technic.register_group_resistance function --- technic/doc/api.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/technic/doc/api.md b/technic/doc/api.md index 1c731ee3..453f7c23 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -149,6 +149,10 @@ Unsorted functions: * Sets the radiation resistance of the given node. * `node_name`: name of the node * `resistance`: number, radiation resistance of the node +* `technic.register_group_resistance(group_name, resistance)` + * Sets the radiation resistance of the given group of nodes. + * `group_name`: name of the group + * `resistance`: number, radiation resistance of the group ### Energy modifiers * `technic.set_RE_wear(itemstack, item_load, max_charge)` From 5b8e7fb472c91bab5bb1d20ebde37de7279e7827 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 19 Oct 2024 03:19:34 -0500 Subject: [PATCH 13/19] Update nodes.lua Added rad_resistance group to resistant nodes. --- technic_worldgen/nodes.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/technic_worldgen/nodes.lua b/technic_worldgen/nodes.lua index d7c1bab0..336c65b8 100644 --- a/technic_worldgen/nodes.lua +++ b/technic_worldgen/nodes.lua @@ -5,7 +5,7 @@ minetest.register_node( ":technic:mineral_uranium", { description = S("Uranium Ore"), tiles = { "default_stone.png^technic_mineral_uranium.png" }, is_ground_content = true, - groups = {cracky=3, radioactive=1}, + groups = {cracky=3, radioactive=1, rad_resistance=71}, sounds = default.node_sound_stone_defaults(), drop = "technic:uranium_lump", }) @@ -14,7 +14,7 @@ minetest.register_node( ":technic:mineral_chromium", { description = S("Chromium Ore"), tiles = { "default_stone.png^technic_mineral_chromium.png" }, is_ground_content = true, - groups = {cracky=3}, + groups = {cracky=3, rad_resistance=19}, sounds = default.node_sound_stone_defaults(), drop = "technic:chromium_lump", }) @@ -23,7 +23,7 @@ minetest.register_node( ":technic:mineral_zinc", { description = S("Zinc Ore"), tiles = { "default_stone.png^technic_mineral_zinc.png" }, is_ground_content = true, - groups = {cracky=3}, + groups = {cracky=3, rad_resistance=19}, sounds = default.node_sound_stone_defaults(), drop = "technic:zinc_lump", }) @@ -50,7 +50,7 @@ minetest.register_node( ":technic:granite", { description = S("Granite"), tiles = { "technic_granite.png" }, is_ground_content = true, - groups = {cracky=1}, + groups = {cracky=1, rad_resistance=18}, sounds = default.node_sound_stone_defaults(), }) @@ -58,7 +58,7 @@ minetest.register_node( ":technic:granite_bricks", { description = S("Granite Bricks"), tiles = { "technic_granite_bricks.png" }, is_ground_content = false, - groups = {cracky=1}, + groups = {cracky=1, rad_resistance=18}, sounds = default.node_sound_stone_defaults(), }) @@ -66,7 +66,7 @@ minetest.register_node( ":technic:marble", { description = S("Marble"), tiles = { "technic_marble.png" }, is_ground_content = true, - groups = {cracky=3, marble=1}, + groups = {cracky=3, marble=1, rad_resistance=18}, sounds = default.node_sound_stone_defaults(), }) @@ -74,7 +74,7 @@ minetest.register_node( ":technic:marble_bricks", { description = S("Marble Bricks"), tiles = { "technic_marble_bricks.png" }, is_ground_content = false, - groups = {cracky=3}, + groups = {cracky=3, rad_resistance=18}, sounds = default.node_sound_stone_defaults(), }) @@ -90,7 +90,7 @@ minetest.register_node(":technic:chromium_block", { description = S("Chromium Block"), tiles = { "technic_chromium_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=37}, sounds = default.node_sound_stone_defaults() }) @@ -98,7 +98,7 @@ minetest.register_node(":technic:zinc_block", { description = S("Zinc Block"), tiles = { "technic_zinc_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=36}, sounds = default.node_sound_stone_defaults() }) @@ -121,7 +121,7 @@ minetest.register_node(":technic:cast_iron_block", { description = S("Cast Iron Block"), tiles = { "technic_cast_iron_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=40}, sounds = default.node_sound_stone_defaults() }) @@ -129,7 +129,7 @@ minetest.register_node(":technic:carbon_steel_block", { description = S("Carbon Steel Block"), tiles = { "technic_carbon_steel_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=40}, sounds = default.node_sound_stone_defaults() }) @@ -137,7 +137,7 @@ minetest.register_node(":technic:stainless_steel_block", { description = S("Stainless Steel Block"), tiles = { "technic_stainless_steel_block.png" }, is_ground_content = true, - groups = {cracky=1, level=2}, + groups = {cracky=1, level=2, rad_resistance=40}, sounds = default.node_sound_stone_defaults() }) From 60b22e3c3a9a6b6f2141142511235ebc3495b782 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 19 Oct 2024 03:20:19 -0500 Subject: [PATCH 14/19] Update radiation.lua Technic specific node resistances moved to node definitions. --- technic/radiation.lua | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index d7ab44a6..30365362 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -158,20 +158,8 @@ local node_resistances = { ["moreores:silver_block"] = 53, ["snow:snow_brick"] = 2.8, ["basic_materials:brass_block"] = 43, - ["technic:carbon_steel_block"] = 40, - ["technic:cast_iron_block"] = 40, - ["technic:chernobylite_block"] = 40, - ["technic:chromium_block"] = 37, ["technic:corium_flowing"] = 40, ["technic:corium_source"] = 80, - ["technic:granite"] = 18, - ["technic:marble"] = 18, - ["technic:marble_bricks"] = 18, - ["technic:mineral_chromium"] = 19, - ["technic:mineral_uranium"] = 71, - ["technic:mineral_zinc"] = 19, - ["technic:stainless_steel_block"] = 40, - ["technic:zinc_block"] = 36, ["tnt:tnt"] = 11, ["tnt:tnt_burning"] = 11, } @@ -471,7 +459,7 @@ minetest.register_node("technic:chernobylite_block", { description = S("Chernobylite Block"), tiles = {"technic_chernobylite_block.png"}, is_ground_content = true, - groups = {cracky=1, radioactive=4, level=2}, + groups = {cracky=1, radioactive=4, level=2, rad_resistance=40}, sounds = default.node_sound_stone_defaults(), light_source = 2, }) From f9026bfacf2651c2d112cdf8bb6b1914c253fc5b Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sat, 19 Oct 2024 06:59:22 -0500 Subject: [PATCH 15/19] Update radiation.lua Why is whitespace such an issue? There's nothing there. --- technic/radiation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 30365362..59e55754 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -197,7 +197,7 @@ local function node_radiation_resistance(node_name) if def.groups.rad_resistance then resistance = resistance + def.groups.rad_resistance end - + return math.sqrt(resistance) end From af6ab2899e8f6aae38308da230647941e9dd1c14 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:00:11 -0500 Subject: [PATCH 16/19] Update radiation.lua I thought I removed the white space already... --- technic/radiation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 59e55754..55860c48 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -197,7 +197,7 @@ local function node_radiation_resistance(node_name) if def.groups.rad_resistance then resistance = resistance + def.groups.rad_resistance end - + return math.sqrt(resistance) end From cf01860727614f49bbdf073b4ba055016ef45165 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sun, 20 Oct 2024 10:16:13 -0500 Subject: [PATCH 17/19] Update radiation.lua I think this will work? --- technic/radiation.lua | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 55860c48..9d0cede0 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -185,22 +185,30 @@ technic.register_group_resistance("tree", 3.4) technic.register_group_resistance("uranium_block", 500) technic.register_group_resistance("wood", 1.7) --- Function to calculate radiation resistance -local function node_radiation_resistance(node_name) - local def = minetest.registered_nodes[node_name] - if not def then - return 0 - end +technic.resistance_cache = {} - local resistance = 0 - -- Add rad_resistance group value if it exists - if def.groups.rad_resistance then - resistance = resistance + def.groups.rad_resistance +function technic.cache_resistances() + for node_name, node_def in pairs(minetest.registered_nodes) do + local resistance = 0 + if node_def.groups and node_def.groups.rad_resistance then + resistance = node_def.groups.rad_resistance + end + technic.resistance_cache[node_name] = resistance end +end - return math.sqrt(resistance) +local function node_radiation_resistance(node_name) + local cached_resistance = technic.resistance_cache[node_name] + if cached_resistance then + return math.sqrt(cached_resistance) + else + return 0 + end end +-- Initialize cache +technic.cache_resistances() + --[[ Radioactive nodes cause damage to nearby players. The damage effect depends on the intrinsic strength of the radiation source, From feb853c715d856327c1931e6c93df507ef1cb64c Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Sun, 20 Oct 2024 10:16:37 -0500 Subject: [PATCH 18/19] Update api.md Radiation functions moved to Radiation section. --- technic/doc/api.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/technic/doc/api.md b/technic/doc/api.md index 453f7c23..59bdee93 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -145,14 +145,6 @@ Unsorted functions: * Some configuration function * `technic.tube_inject_item(pos, start_pos, velocity, item)` * Same as `pipeworks.tube_inject_item` -* `technic.register_rad_resistance(node_name, resistance)` - * Sets the radiation resistance of the given node. - * `node_name`: name of the node - * `resistance`: number, radiation resistance of the node -* `technic.register_group_resistance(group_name, resistance)` - * Sets the radiation resistance of the given group of nodes. - * `group_name`: name of the group - * `resistance`: number, radiation resistance of the group ### Energy modifiers * `technic.set_RE_wear(itemstack, item_load, max_charge)` @@ -280,6 +272,20 @@ Network functionality: 5. If the total demand is more than the available power all RE nodes will be shut down. We have a brown-out situation. + +## Radiation +* `technic.register_rad_resistance(node_name, resistance)` + * Sets the radiation resistance of the given node. + * `node_name`: name of the node + * `resistance`: number, radiation resistance of the node +* `technic.register_group_resistance(group_name, resistance)` + * Sets the radiation resistance of the given group of nodes. + * `group_name`: name of the group + * `resistance`: number, radiation resistance of the group +* `technic.cache_resistances()` + * Cache radiation resistances after Technic loads. + + ## Deprecated functions Following functions are either no longer used by technic, or are planned to From 28a906863db6e3171901fe2f8cf43c09de9138d6 Mon Sep 17 00:00:00 2001 From: DustyDave961 <144002335+DustyDave961@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:08:00 -0600 Subject: [PATCH 19/19] Update radiation.lua Shouldn't the resistance cache be initialized before the node_radiation_resistance function? --- technic/radiation.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/technic/radiation.lua b/technic/radiation.lua index 9d0cede0..47f9eb6c 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -185,6 +185,7 @@ technic.register_group_resistance("tree", 3.4) technic.register_group_resistance("uranium_block", 500) technic.register_group_resistance("wood", 1.7) +--Radiation resistances cache technic.resistance_cache = {} function technic.cache_resistances() @@ -197,6 +198,8 @@ function technic.cache_resistances() end end +technic.cache_resistances() + local function node_radiation_resistance(node_name) local cached_resistance = technic.resistance_cache[node_name] if cached_resistance then @@ -206,9 +209,6 @@ local function node_radiation_resistance(node_name) end end --- Initialize cache -technic.cache_resistances() - --[[ Radioactive nodes cause damage to nearby players. The damage effect depends on the intrinsic strength of the radiation source,