Skip to content

Commit

Permalink
Update radiation.lua
Browse files Browse the repository at this point in the history
I think this will work?
  • Loading branch information
DustyDave961 authored Oct 20, 2024
1 parent af6ab28 commit cf01860
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions technic/radiation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cf01860

Please sign in to comment.