mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Merge pull request #522 from iltar/command-cleanup
Cleaned up some diggy commands and the left-overs register in _DEBUG
This commit is contained in:
commit
5c1bafe55e
@ -71,9 +71,6 @@ local Config = {
|
||||
-- primarily used for multiplayer, can be disabled without consequences
|
||||
enable_digging_warning = true,
|
||||
|
||||
-- enables commands like /clear-void
|
||||
enable_debug_commands = false,
|
||||
|
||||
-- initial damage per tick it damages a rock to mine, can be enhanced by robot_damage_per_mining_prod_level
|
||||
robot_initial_mining_damage = 4,
|
||||
|
||||
@ -91,9 +88,6 @@ local Config = {
|
||||
-- shows the mask on spawn
|
||||
enable_mask_debug = false,
|
||||
|
||||
-- enables commands like /test-tile-support-range
|
||||
enable_debug_commands = false,
|
||||
|
||||
--the size of the mask used
|
||||
mask_size = 9,
|
||||
|
||||
|
@ -13,7 +13,6 @@ local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Game = require 'utils.game'
|
||||
local CreateParticles = require 'features.create_particles'
|
||||
local insert = table.insert
|
||||
local random = math.random
|
||||
local floor = math.floor
|
||||
local abs = math.abs
|
||||
@ -182,8 +181,6 @@ local function spawn_cracking_sound_text(surface, position)
|
||||
end
|
||||
|
||||
local function on_collapse_triggered(event)
|
||||
if global.cave_collapse_disabled then return end --kill switch
|
||||
|
||||
local surface = event.surface
|
||||
local position = event.position
|
||||
local x = position.x
|
||||
@ -414,61 +411,6 @@ to reinforce it further.
|
||||
Debug.print_grid_value(fraction, surface, {x = x, y = y})
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
if config.enable_debug_commands then
|
||||
commands.add_command('test-tile-support-range', '<tilename> <range> creates a square of tiles with length <range>. It is spawned one <range> north of the player.', function(cmd)
|
||||
local params = {}
|
||||
for param in string.gmatch(cmd.parameter, '%S+') do
|
||||
table.insert(params, param)
|
||||
end
|
||||
|
||||
local tilename = params[1]
|
||||
local range = tonumber(params[2])
|
||||
|
||||
local position = {x = math.floor(game.player.position.x), y = math.floor(game.player.position.y) - 5 * range - 1}
|
||||
local surface = game.player.surface
|
||||
local tiles = {}
|
||||
local entities = {}
|
||||
for x = position.x, position.x + range * 5 do
|
||||
for y = position.y, position.y + range * 5 do
|
||||
if y % range + x % range == 0 then
|
||||
insert(entities,{name = 'stone-wall', position = {x=x,y=y}})
|
||||
end
|
||||
insert(tiles, {position = {x = x, y = y}, name = tilename})
|
||||
|
||||
local strength = support_beam_entities[tilename]
|
||||
if strength then
|
||||
stress_map_add(surface, {x = x, y = y}, - strength)
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered({position = {x = x, y = y}})) do
|
||||
pcall(function()
|
||||
local local_strength = support_beam_entities[entity.name]
|
||||
local local_position = entity.position
|
||||
entity.die()
|
||||
if strength then
|
||||
stress_map_add(surface, local_position, local_strength)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
Template.insert(surface, tiles, entities)
|
||||
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
|
||||
global.cave_collapse_disabled = not global.cave_collapse_disabled
|
||||
if global.cave_collapse_disabled then
|
||||
game.print('Cave collapse: Disabled.')
|
||||
else
|
||||
game.print('Cave collapse: Enabled.')
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
--
|
||||
|
@ -9,8 +9,10 @@ local Global = require 'utils.global'
|
||||
local Template = require 'map_gen.Diggy.Template'
|
||||
local ScoreTable = require 'map_gen.Diggy.ScoreTable'
|
||||
local Debug = require 'map_gen.Diggy.Debug'
|
||||
local Command = require 'utils.command'
|
||||
local CreateParticles = require 'features.create_particles'
|
||||
local random = math.random
|
||||
local tonumber = tonumber
|
||||
local raise_event = script.raise_event
|
||||
|
||||
-- this
|
||||
@ -118,6 +120,27 @@ local function on_mined_tile(surface, tiles)
|
||||
|
||||
Template.insert(surface, new_tiles, {})
|
||||
end
|
||||
Command.add('diggy-clear-void', {
|
||||
description = 'Clears the void in a given area but still triggers all events Diggy would when clearing void.',
|
||||
arguments = {'left_top_x', 'left_top_y', 'width', 'height', 'surface_index'},
|
||||
debug_only = true,
|
||||
admin_only = true,
|
||||
}, function(arguments)
|
||||
local left_top_x = tonumber(arguments.left_top_x)
|
||||
local left_top_y = tonumber(arguments.left_top_y)
|
||||
local width = tonumber(arguments.width)
|
||||
local height = tonumber(arguments.height)
|
||||
local tiles = {}
|
||||
local count = 0
|
||||
for x = 0, width do
|
||||
for y = 0, height do
|
||||
count = count + 1
|
||||
tiles[count] = {name = 'dirt-' .. random(1, 7), position = {x = x + left_top_x, y = y + left_top_y}}
|
||||
end
|
||||
end
|
||||
|
||||
Template.insert(game.surfaces[arguments.surface_index], tiles, {})
|
||||
end)
|
||||
|
||||
--[[--
|
||||
Registers all event handlers.
|
||||
@ -223,37 +246,6 @@ function DiggyHole.register(config)
|
||||
robot_mining.research_modifier = new_modifier
|
||||
update_robot_mining_damage()
|
||||
end)
|
||||
|
||||
if config.enable_debug_commands then
|
||||
commands.add_command('clear-void', '<left top x> <left top y> <width> <height> <surface index> triggers Template.insert for the given area.', function(cmd)
|
||||
local params = {}
|
||||
local args = cmd.parameter or ''
|
||||
for param in string.gmatch(args, '%S+') do
|
||||
table.insert(params, param)
|
||||
end
|
||||
|
||||
if (#params ~= 5) then
|
||||
game.player.print('/clear-void requires exactly 5 arguments: <left top x> <left top y> <width> <height> <surface index>')
|
||||
return
|
||||
end
|
||||
|
||||
local left_top_x = tonumber(params[1])
|
||||
local left_top_y = tonumber(params[2])
|
||||
local width = tonumber(params[3])
|
||||
local height = tonumber(params[4])
|
||||
local surface_index = params[5]
|
||||
local tiles = {}
|
||||
local count = 0
|
||||
for x = 0, width do
|
||||
for y = 0, height do
|
||||
count = count + 1
|
||||
tiles[count] = {name = 'dirt-' .. random(1, 7), position = {x = x + left_top_x, y = y + left_top_y}}
|
||||
end
|
||||
end
|
||||
|
||||
Template.insert(game.surfaces[surface_index], tiles, {})
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function DiggyHole.on_init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user