1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-05 15:05:57 +02:00

fixed double crack warning and implemented kill siwtch

This commit is contained in:
Maik Wild 2018-10-13 15:02:18 +02:00
parent 5c6f92a5bc
commit a445b5719c

View File

@ -49,6 +49,7 @@ local deconstruction_alert_message_shown = {}
local stress_map_storage = {}
local new_tile_map = {}
local collapse_positions_storage = {}
local cave_collapse_disabled = nil
Global.register({
@ -56,11 +57,13 @@ Global.register({
stress_map_storage = stress_map_storage,
deconstruction_alert_message_shown = deconstruction_alert_message_shown,
collapse_positions_storage = collapse_positions_storage,
cave_collapse_disabled = cave_collapse_disabled,
}, function(tbl)
new_tile_map = tbl.new_tile_map
stress_map_storage = tbl.stress_map_storage
deconstruction_alert_message_shown = tbl.deconstruction_alert_message_shown
collapse_positions_storage = tbl.collapse_positions_storage
cave_collapse_disabled = tbl.cave_collapse_disabled
end)
local defaultValue = 0
@ -176,6 +179,9 @@ local function execute_collapses()
end
local function on_collapse_triggered(event)
if cave_collapse_disabled then return end --kill switch
local surface = event.surface
local position = event.position
local x = position.x
@ -357,6 +363,19 @@ function DiggyCaveCollapse.register(cfg)
Debug.print_grid_value(fraction, surface, {x = x, y = y})
end)
end
commands.add_command('toggle-cave-collapse', 'Toggles cave collapse (admins only).', function()
pcall(function() --better safe than sorry
if not game.player or game.player.admin then
cave_collapse_disabled = not cave_collapse_disabled
if cave_collapse_disabled then
game.print("Cave collapse: Disabled.")
else
game.print("Cave collapse: Enabled.")
end
end
end)
end)
end
--
@ -400,7 +419,7 @@ local function add_fraction(stress_map, x, y, fraction, no_collapse)
x_t[y] = value
if (value > stress_threshold_causing_collapse) then
if (value > stress_threshold_causing_collapse and fraction > 0) then
if quadrant > 2 then
y = -y
end
@ -443,7 +462,7 @@ local function add_fraction_by_quadrant(stress_map, x, y, fraction, quadrant)
x_t[y] = value
if (value > stress_threshold_causing_collapse) then
if (value > stress_threshold_causing_collapse and fraction > 0) then
local index = quadrant.index
if index > 2 then
y = -y
@ -503,7 +522,6 @@ end
stress_map_blur_add = function(surface, position, factor)
local x_start = floor(position.x)
local y_start = floor(position.y)