mirror of
https://github.com/minetest-mods/technic.git
synced 2025-02-05 06:40:31 +01:00
Update radiation.lua
Spaces bothered me.
This commit is contained in:
parent
cedccb4401
commit
2309259f64
@ -34,8 +34,8 @@ local cache_radiation_resistance = {}
|
|||||||
|
|
||||||
-- Function to register node-specific resistance
|
-- Function to register node-specific resistance
|
||||||
function technic.register_rad_resistance(node_name, resistance)
|
function technic.register_rad_resistance(node_name, resistance)
|
||||||
rad_resistance_node[node_name] = resistance
|
rad_resistance_node[node_name] = resistance
|
||||||
cache_radiation_resistance[node_name] = nil -- Invalidate cache
|
cache_radiation_resistance[node_name] = nil -- Invalidate cache
|
||||||
end
|
end
|
||||||
|
|
||||||
local S = technic.getter
|
local S = technic.getter
|
||||||
@ -177,18 +177,18 @@ local node_resistances = {
|
|||||||
|
|
||||||
-- Register all node resistances at once
|
-- Register all node resistances at once
|
||||||
for node_name, resistance in pairs(node_resistances) do
|
for node_name, resistance in pairs(node_resistances) do
|
||||||
technic.register_rad_resistance(node_name, resistance)
|
technic.register_rad_resistance(node_name, resistance)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function to register group-specific resistance
|
-- Function to register group-specific resistance
|
||||||
function technic.register_group_resistance(group_name, resistance)
|
function technic.register_group_resistance(group_name, resistance)
|
||||||
rad_resistance_group[group_name] = resistance
|
rad_resistance_group[group_name] = resistance
|
||||||
-- Invalidate cache for all nodes in this group
|
-- Invalidate cache for all nodes in this group
|
||||||
for node_name, def in pairs(minetest.registered_nodes) do
|
for node_name, def in pairs(minetest.registered_nodes) do
|
||||||
if def.groups[group_name] then
|
if def.groups[group_name] then
|
||||||
cache_radiation_resistance[node_name] = nil
|
cache_radiation_resistance[node_name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
technic.register_group_resistance("concrete", 16)
|
technic.register_group_resistance("concrete", 16)
|
||||||
@ -198,39 +198,39 @@ technic.register_group_resistance("wood", 1.7)
|
|||||||
|
|
||||||
-- Function to calculate radiation resistance
|
-- Function to calculate radiation resistance
|
||||||
function node_radiation_resistance(node_name)
|
function node_radiation_resistance(node_name)
|
||||||
local resistance = cache_radiation_resistance[node_name]
|
local resistance = cache_radiation_resistance[node_name]
|
||||||
if resistance then
|
if resistance then
|
||||||
return resistance
|
return resistance
|
||||||
end
|
end
|
||||||
local def = minetest.registered_nodes[node_name]
|
local def = minetest.registered_nodes[node_name]
|
||||||
if not def then
|
if not def then
|
||||||
cache_radiation_resistance[node_name] = 0
|
cache_radiation_resistance[node_name] = 0
|
||||||
return 0
|
return 0
|
||||||
end
|
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
|
||||||
|
|
||||||
-- Check for rad_resistance group in node definition
|
-- If no rad_resistance group, use registered node-specific resistance
|
||||||
resistance = 0
|
if resistance >= 0 then
|
||||||
for g, v in pairs(def.groups) do
|
resistance = rad_resistance_node[node_name] or 0
|
||||||
if g == "rad_resistance" then
|
end
|
||||||
resistance = resistance + v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If no rad_resistance group, use registered node-specific resistance
|
-- Add group-specific resistance if applicable
|
||||||
if resistance >= 0 then
|
for g, v in pairs(def.groups) do
|
||||||
resistance = rad_resistance_node[node_name] or 0
|
if v > 0 and rad_resistance_group[g] then
|
||||||
end
|
resistance = resistance + rad_resistance_group[g]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Add group-specific resistance if applicable
|
resistance = math.sqrt(resistance)
|
||||||
for g, v in pairs(def.groups) do
|
cache_radiation_resistance[node_name] = resistance
|
||||||
if v > 0 and rad_resistance_group[g] then
|
return resistance
|
||||||
resistance = resistance + rad_resistance_group[g]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
resistance = math.sqrt(resistance)
|
|
||||||
cache_radiation_resistance[node_name] = resistance
|
|
||||||
return resistance
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
Loading…
Reference in New Issue
Block a user