Update radiation.lua

I think this will work?
This commit is contained in:
DustyDave961 2024-10-20 10:16:13 -05:00 committed by GitHub
parent af6ab2899e
commit cf01860727
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -185,22 +185,30 @@ technic.register_group_resistance("tree", 3.4)
technic.register_group_resistance("uranium_block", 500) technic.register_group_resistance("uranium_block", 500)
technic.register_group_resistance("wood", 1.7) technic.register_group_resistance("wood", 1.7)
-- Function to calculate radiation resistance technic.resistance_cache = {}
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
local function node_radiation_resistance(node_name) local function node_radiation_resistance(node_name)
local def = minetest.registered_nodes[node_name] local cached_resistance = technic.resistance_cache[node_name]
if not def then if cached_resistance then
return math.sqrt(cached_resistance)
else
return 0 return 0
end end
local resistance = 0
-- Add rad_resistance group value if it exists
if def.groups.rad_resistance then
resistance = resistance + def.groups.rad_resistance
end
return math.sqrt(resistance)
end end
-- Initialize cache
technic.cache_resistances()
--[[ --[[
Radioactive nodes cause damage to nearby players. The damage Radioactive nodes cause damage to nearby players. The damage
effect depends on the intrinsic strength of the radiation source, effect depends on the intrinsic strength of the radiation source,