mirror of
https://github.com/minetest-mods/technic.git
synced 2025-02-05 06:40:31 +01:00
Update radiation.lua
I think this will work?
This commit is contained in:
parent
af6ab2899e
commit
cf01860727
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user