From 0d131dffc6d062a55062a0c75c90098a9b184a5e Mon Sep 17 00:00:00 2001 From: grilledham Date: Tue, 2 Oct 2018 15:37:46 +0100 Subject: [PATCH 01/12] updated regs --- resources/regulars.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/resources/regulars.lua b/resources/regulars.lua index ba0c3736..59be2275 100644 --- a/resources/regulars.lua +++ b/resources/regulars.lua @@ -979,5 +979,21 @@ return { ['crayzz2'] = true, ['Gerkiz'] = true, ['piterfersin'] = true, - ['SiMoZ_287'] = true + ['SiMoZ_287'] = true, + ['SSeltmann'] = true, + ['AbsoluteZeroIs0K'] = true, + ['jufacto'] = true, + ['okan009'] = true, + ['CounterfeitThe'] = true, + ['TZsec'] = true, + ['jamesh92'] = true, + ['Flameoguy'] = true, + ['Toledini'] = true, + ['alnmike'] = true, + ['Krzys132'] = true, + ['jrz126'] = true, + ['Rothguard'] = true, + ['Rascher'] = true, + ['XeoXius'] = true, + ['InphinitePhractals'] = true } From 99283af7e4a56be776e2665dc557b39fa797eccc Mon Sep 17 00:00:00 2001 From: grilledham Date: Tue, 2 Oct 2018 20:54:13 +0100 Subject: [PATCH 02/12] donator welcome messages are in the player's color --- control.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/control.lua b/control.lua index 3fe0f89f..a2baa426 100644 --- a/control.lua +++ b/control.lua @@ -32,7 +32,6 @@ require 'paint' require 'score' require 'popup' - local Event = require 'utils.event' local Donators = require 'resources.donators' @@ -167,7 +166,7 @@ local function player_joined(event) return end - game.print(table.concat({'*** ', message, ' ***'})) + game.print(table.concat({'*** ', message, ' ***'}), player.chat_color) end Event.add(defines.events.on_player_created, player_created) From 8a5a3d2ee08d1e3b43489e980790870f469f63bd Mon Sep 17 00:00:00 2001 From: Valansch Date: Wed, 3 Oct 2018 17:29:36 +0200 Subject: [PATCH 03/12] Update donators.lua --- resources/donators.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/donators.lua b/resources/donators.lua index a5db5f86..abcb059d 100644 --- a/resources/donators.lua +++ b/resources/donators.lua @@ -25,7 +25,8 @@ Module.donators = { Module.welcome_messages = { ['Linaori'] = 'I present to you Linaori of house Refactorio, Lady of the Void, Remover of Spaghetti, Queen of the Endless Nauvis, Breaker of Biters and Mother of Code!', ['Valansch'] = 'Welcome Valansch, .', - ['der-dave.com'] = "Dave doesn't want a welcome message." + ['der-dave.com'] = 'Dave doesn\'t want a welcome message.', + ['robertkruijt'] = 'The general of the army has arived!' } return Module From 554e1fea5178af12e39b672ffa0841d561791f7c Mon Sep 17 00:00:00 2001 From: Valansch Date: Thu, 4 Oct 2018 10:53:35 +0200 Subject: [PATCH 04/12] autoban barcodes --- nuke_control.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nuke_control.lua b/nuke_control.lua index 11756393..eb59627f 100644 --- a/nuke_control.lua +++ b/nuke_control.lua @@ -143,7 +143,15 @@ local function on_capsule_used(event) end end +local function on_player_joined(event) + local player = game.players[event.player_index] + if string.match(player.name,"^[Ili1|]+$") then + game.ban_player(player) --No reason given, to not give them any hints to change their name + end +end + Event.add(defines.events.on_player_ammo_inventory_changed, ammo_changed) +Event.add(defines.events.on_player_joined_game, on_player_joined) Event.add(defines.events.on_player_deconstructed_area, on_player_deconstructed_area) --Event.add(defines.events.on_player_mined_entity, on_player_mined_item) Event.add(defines.events.on_player_used_capsule, on_capsule_used) From 075f728e960a6cf4cb4f2a49ede172ae3e352f16 Mon Sep 17 00:00:00 2001 From: grilledham Date: Sat, 6 Oct 2018 13:46:06 +0100 Subject: [PATCH 05/12] updated regs --- resources/regulars.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/regulars.lua b/resources/regulars.lua index 59be2275..5b198871 100644 --- a/resources/regulars.lua +++ b/resources/regulars.lua @@ -995,5 +995,8 @@ return { ['Rothguard'] = true, ['Rascher'] = true, ['XeoXius'] = true, - ['InphinitePhractals'] = true + ['InphinitePhractals'] = true, + ['Breadface'] = true, + ['safariursis'] = true, + ['Marucan'] = true } From 3b76740adc81ab10dd3a7f8043120962c4578933 Mon Sep 17 00:00:00 2001 From: grilledham Date: Sat, 6 Oct 2018 13:46:18 +0100 Subject: [PATCH 06/12] map double beach --- map_gen/presets/double_beach.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 map_gen/presets/double_beach.lua diff --git a/map_gen/presets/double_beach.lua b/map_gen/presets/double_beach.lua new file mode 100644 index 00000000..480dc1ef --- /dev/null +++ b/map_gen/presets/double_beach.lua @@ -0,0 +1,15 @@ +local b = require 'map_gen.shared.builders' + +local beach = require 'map_gen.presets.beach' + +local start_pound = b.circle(6) +start_pound = b.translate(start_pound, 0, -16) +start_pound = b.change_tile(start_pound, true, 'water') + +beach = b.translate(beach, 0, -64) + +local map = b.any {start_pound, beach, b.translate(b.flip_y(beach), -51200, 0)} + +map = b.rotate(map, degrees(45)) + +return map From 044adcf0ed2b6783a854c01c4a88ecc5e59ce35c Mon Sep 17 00:00:00 2001 From: grilledham Date: Sat, 6 Oct 2018 13:46:32 +0100 Subject: [PATCH 07/12] updates to beach map --- map_gen/presets/beach.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map_gen/presets/beach.lua b/map_gen/presets/beach.lua index 182edc4f..3135f7fc 100644 --- a/map_gen/presets/beach.lua +++ b/map_gen/presets/beach.lua @@ -91,7 +91,7 @@ sand_shape = b.apply_entity(sand_shape, do_ores) water_shape = b.change_tile(water_shape, true, 'water') -local oil = b.resource(b.full_shape, 'crude-oil', value(500000, 2500)) +local oil = b.resource(b.full_shape, 'crude-oil', value(300000, 2000)) local function do_oil(x, y, world) if math.random(16384) == 1 then local e = oil(x, y, world) From 340c8a06730ec694b8d4c921e509d5fb70b2018e Mon Sep 17 00:00:00 2001 From: grilledham Date: Sat, 6 Oct 2018 17:07:50 +0100 Subject: [PATCH 08/12] added double beach --- map_layout.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/map_layout.lua b/map_layout.lua index 27f38d8b..613dcd92 100644 --- a/map_layout.lua +++ b/map_layout.lua @@ -68,6 +68,7 @@ local tiles_per_tick = 32 --shape = require "map_gen.presets.line_and_tree" --shape = require "map_gen.presets.square_spiral" --shape = require "map_gen.presets.beach" +--shape = require "map_gen.presets.double_beach" --shape = require "map_gen.presets.factory" --shape = require "map_gen.presets.triangle_of_death" --shape = require "map_gen.presets.world_map" From 84e1d96fcc68e888ef36b80a9d904150119bd621 Mon Sep 17 00:00:00 2001 From: grilledham Date: Sun, 7 Oct 2018 15:49:12 +0100 Subject: [PATCH 09/12] map info text boxes now word wrap --- info.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/info.lua b/info.lua index 103bc9e1..903a6987 100644 --- a/info.lua +++ b/info.lua @@ -21,10 +21,7 @@ local new_info_key = 4 local welcomed_players = {} local editable_info = { [map_name_key] = 'This Map has no name', - [map_description_key] = [[ -By default this section is blank as it's supposed to be filled out on a per map basis. -(If you're seeing this message, ping the admin team to get a description added for -this map)]], + [map_description_key] = "By default this section is blank as it's supposed to be filled out on a per map basis. (If you're seeing this message, ping the admin team to get a description added for this map)", [map_extra_info_key] = 'This map has no extra infomation', [new_info_key] = 'Nothing is new. The world is at peace' } @@ -405,6 +402,7 @@ Shows number of rockets launched and biters liberated.]] text = editable_info[map_name_key] } map_name_textbox.read_only = read_only + map_name_textbox.word_wrap = true local map_name_textbox_style = map_name_textbox.style map_name_textbox_style.width = text_width @@ -420,6 +418,7 @@ Shows number of rockets launched and biters liberated.]] text = editable_info[map_description_key] } map_description_textbox.read_only = read_only + map_description_textbox.word_wrap = true local map_description_textbox_style = map_description_textbox.style map_description_textbox_style.width = text_width @@ -435,6 +434,7 @@ Shows number of rockets launched and biters liberated.]] text = editable_info[map_extra_info_key] } map_extra_info_textbox.read_only = read_only + map_extra_info_textbox.word_wrap = true local map_extra_info_textbox_style = map_extra_info_textbox.style map_extra_info_textbox_style.width = text_width @@ -705,7 +705,7 @@ Gui.on_custom_close( local Public = {} -function Public.get_map_name() +function Public.get_map_name() return editable_info[map_name_key] end @@ -713,7 +713,7 @@ function Public.set_map_name(value) editable_info[map_name_key] = value end -function Public.get_map_description() +function Public.get_map_description() return editable_info[map_description_key] end @@ -721,7 +721,7 @@ function Public.set_map_description(value) editable_info[map_description_key] = value end -function Public.get_map_extra_info() +function Public.get_map_extra_info() return editable_info[map_extra_info_key] end @@ -729,7 +729,7 @@ function Public.set_map_extra_info(value) editable_info[map_extra_info_key] = value end -function Public.get_new_info() +function Public.get_new_info() return editable_info[new_info_key] end From b799da20e34599c768200609d2be9af91a770397 Mon Sep 17 00:00:00 2001 From: Lynn Date: Sun, 7 Oct 2018 17:05:59 +0200 Subject: [PATCH 10/12] Added map extra info for each scenario --- map_gen/Diggy/Feature/AlienSpawner.lua | 9 +++++++-- map_gen/Diggy/Feature/DiggyCaveCollapse.lua | 11 ++++++++--- map_gen/Diggy/Feature/DiggyHole.lua | 2 +- map_gen/Diggy/Feature/MarketExchange.lua | 10 ++++++---- map_gen/Diggy/Feature/MiningEfficiency.lua | 9 ++++++--- map_gen/Diggy/Feature/ScatteredResources.lua | 8 ++++++-- map_gen/Diggy/Feature/SetupPlayer.lua | 4 ++-- map_gen/Diggy/Feature/SimpleRoomGenerator.lua | 8 +++++--- map_gen/Diggy/Feature/StartingZone.lua | 4 ++-- map_gen/Diggy/Scenario.lua | 7 +++---- 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/map_gen/Diggy/Feature/AlienSpawner.lua b/map_gen/Diggy/Feature/AlienSpawner.lua index c2fd65a2..68430fab 100644 --- a/map_gen/Diggy/Feature/AlienSpawner.lua +++ b/map_gen/Diggy/Feature/AlienSpawner.lua @@ -32,8 +32,7 @@ end --[[-- Registers all event handlers. ]] -function AlienSpawner.register(cfg) - local config = cfg.features.AlienSpawner +function AlienSpawner.register(config) local alien_minimum_distance_square = config.alien_minimum_distance ^ 2 Event.add(Template.events.on_void_removed, function(event) @@ -48,4 +47,10 @@ function AlienSpawner.register(cfg) end) end +function AlienSpawner.get_extra_map_info(config) + return [[Alien Spawner, aliens might spawn when mining! +Spawn chance: ]] .. (config.alien_probability * 100) .. [[% +Minimum spawn distance: ]] .. config.alien_minimum_distance .. ' tiles' +end + return AlienSpawner diff --git a/map_gen/Diggy/Feature/DiggyCaveCollapse.lua b/map_gen/Diggy/Feature/DiggyCaveCollapse.lua index bf0e3359..f6e88697 100644 --- a/map_gen/Diggy/Feature/DiggyCaveCollapse.lua +++ b/map_gen/Diggy/Feature/DiggyCaveCollapse.lua @@ -93,7 +93,7 @@ local function create_collapse_template(positions, surface) return tiles, entities end -local function collapse(args, surface, position) +local function collapse(args) local position = args.position local surface = args.surface local positions = {} @@ -228,8 +228,8 @@ end @param global_config Table {@see Diggy.Config}. ]] -function DiggyCaveCollapse.register(global_config) - config = global_config.features.DiggyCaveCollapse +function DiggyCaveCollapse.register(cfg) + config = cfg support_beam_entities = config.support_beam_entities Event.add(DiggyCaveCollapse.events.on_collapse_triggered, on_collapse_triggered) @@ -550,4 +550,9 @@ mask_disc_blur = function(x_start, y_start, factor, callback) end end +function DiggyCaveCollapse.get_extra_map_info(config) + return [[Alien Spawner, aliens might spawn when mining! +Place stone walls, stone paths and (refined) concrete to reinforce the mine. If you see cracks appear, run!]] +end + return DiggyCaveCollapse diff --git a/map_gen/Diggy/Feature/DiggyHole.lua b/map_gen/Diggy/Feature/DiggyHole.lua index 3a87caca..8a7d2b82 100644 --- a/map_gen/Diggy/Feature/DiggyHole.lua +++ b/map_gen/Diggy/Feature/DiggyHole.lua @@ -52,7 +52,7 @@ local artificial_tiles = { --[[-- Registers all event handlers. ]] -function DiggyHole.register(cfg) +function DiggyHole.register(config) Event.add(defines.events.on_entity_died, function (event) diggy_hole(event.entity) end) diff --git a/map_gen/Diggy/Feature/MarketExchange.lua b/map_gen/Diggy/Feature/MarketExchange.lua index 012d96b5..ffdd29e5 100644 --- a/map_gen/Diggy/Feature/MarketExchange.lua +++ b/map_gen/Diggy/Feature/MarketExchange.lua @@ -19,9 +19,7 @@ global.MarketExchange = { --[[-- Registers all event handlers. ]] -function MarketExchange.register(cfg) - local config = cfg.features.MarketExchange - +function MarketExchange.register(config) local market_items = { {price = {{config.currency_item, 50}}, offer = {type = 'nothing', effect_description = 'Send ' .. config.stone_to_surface_amount .. ' stone to the surface'}}, } @@ -41,7 +39,7 @@ function MarketExchange.register(cfg) end) Event.on_init(function() - Task.set_timeout_in_ticks(360, on_market_timeout_finished, { + Task.set_timeout_in_ticks(60, on_market_timeout_finished, { currency_item = config.currency_item, market_items = market_items, }) @@ -57,4 +55,8 @@ function MarketExchange.register(cfg) end) end +function MarketExchange.get_extra_map_info(config) + return 'Market Exchange, trade your stone or send it to the surface' +end + return MarketExchange diff --git a/map_gen/Diggy/Feature/MiningEfficiency.lua b/map_gen/Diggy/Feature/MiningEfficiency.lua index 7904bcba..d96c4f29 100644 --- a/map_gen/Diggy/Feature/MiningEfficiency.lua +++ b/map_gen/Diggy/Feature/MiningEfficiency.lua @@ -35,9 +35,7 @@ end --[[-- Registers all event handlers. ]] -function MiningEfficiency.register(cfg) - local config = cfg.features.MiningEfficiency - +function MiningEfficiency.register(config) global.MiningEfficiency.default_mining_speed = config.default_mining_speed Event.add( @@ -53,6 +51,11 @@ function MiningEfficiency.register(cfg) ) end +function MiningEfficiency.get_extra_map_info(config) + return [[Mining Efficiency, increase your mining efficiency by researching mining productivity! +Efficiency increase per level: ]] .. config.mining_speed_productivity_multiplier .. '%' +end + Event.on_init( function() update_mining_speed(game.forces.player) diff --git a/map_gen/Diggy/Feature/ScatteredResources.lua b/map_gen/Diggy/Feature/ScatteredResources.lua index 7d5d1ef1..b3a5d3f5 100644 --- a/map_gen/Diggy/Feature/ScatteredResources.lua +++ b/map_gen/Diggy/Feature/ScatteredResources.lua @@ -50,8 +50,7 @@ end --[[-- Registers all event handlers. ]] -function ScatteredResources.register(cfg) - local config = cfg.features.ScatteredResources +function ScatteredResources.register(config) function sum(t) local sum = 0 for _, v in pairs(t) do @@ -95,4 +94,9 @@ function ScatteredResources.register(cfg) global.ScatteredResources.can_spawn_resources = true end +function ScatteredResources.get_extra_map_info(config) + return [[Scattered Resources, resources are everywhere! +Scans of the mine have shown greater amounts of resources to be deeper in the mine]] +end + return ScatteredResources diff --git a/map_gen/Diggy/Feature/SetupPlayer.lua b/map_gen/Diggy/Feature/SetupPlayer.lua index f2d09a88..8d7cc510 100644 --- a/map_gen/Diggy/Feature/SetupPlayer.lua +++ b/map_gen/Diggy/Feature/SetupPlayer.lua @@ -16,14 +16,14 @@ function SetupPlayer.register(config) Event.add(defines.events.on_player_created, function (event) local player = game.players[event.player_index] - for _, item in pairs(config.features.SetupPlayer.starting_items) do + for _, item in pairs(config.starting_items) do player.insert(item) end player.teleport({x = 0, y = 0}) Debug.cheat(function() - player.force.manual_mining_speed_modifier = config.features.SetupPlayer.cheats.manual_mining_speed_modifier + player.force.manual_mining_speed_modifier = config.cheats.manual_mining_speed_modifier end) end) end diff --git a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua index 9f746d71..5d1cff9f 100644 --- a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua +++ b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua @@ -52,9 +52,7 @@ end local room_noise_minimum_distance_sq -function SimpleRoomGenerator.register(cfg) - local config = cfg.features.SimpleRoomGenerator - +function SimpleRoomGenerator.register(config) room_noise_minimum_distance_sq = config.room_noise_minimum_distance * config.room_noise_minimum_distance local function get_noise(surface, x, y) @@ -90,4 +88,8 @@ function SimpleRoomGenerator.register(cfg) end end +function SimpleRoomGenerator.get_extra_map_info(config) + return 'Simple Room Generator, digging around might open rooms!' +end + return SimpleRoomGenerator diff --git a/map_gen/Diggy/Feature/StartingZone.lua b/map_gen/Diggy/Feature/StartingZone.lua index b4b31d1a..1c9922f9 100644 --- a/map_gen/Diggy/Feature/StartingZone.lua +++ b/map_gen/Diggy/Feature/StartingZone.lua @@ -18,7 +18,7 @@ local daytime ]] function StartingZone.register(config) local callback_token - local starting_zone_size = config.features.StartingZone.starting_size + local starting_zone_size = config.starting_size local function on_chunk_generated(event) local start_point_area = {{-1, -1}, {0, 0}} @@ -68,7 +68,7 @@ function StartingZone.register(config) Event.add_removable(defines.events.on_chunk_generated, callback_token) - daytime = config.features.StartingZone.daytime + daytime = config.daytime end Event.on_init( diff --git a/map_gen/Diggy/Scenario.lua b/map_gen/Diggy/Scenario.lua index 6ff75a59..701d5b13 100644 --- a/map_gen/Diggy/Scenario.lua +++ b/map_gen/Diggy/Scenario.lua @@ -66,17 +66,16 @@ function Scenario.register(debug) error('Feature ' .. feature_name .. ' did not define a register function.') end - feature.register(Config) + feature.register(feature_data) - if ('function' == type(feature.extra_map_info)) then - extra_map_info = extra_map_info .. '\n' .. feature.extra_map_info(Config) + if ('function' == type(feature.get_extra_map_info)) then + extra_map_info = extra_map_info .. feature.get_extra_map_info(feature_data) .. '\n\n' end end ) ScenarioInfo.set_map_name('Diggy') ScenarioInfo.set_map_description('Dig your way through!') - -- Be careful though, the cave might collapse!\nUse stone walls, stone path and concrete to reinforce the cave. ScenarioInfo.set_map_extra_info(extra_map_info) scenario_registered = true From 36168771dd1948bb1e055c9052b64475ef8b0149 Mon Sep 17 00:00:00 2001 From: Lynn Date: Sun, 7 Oct 2018 17:37:29 +0200 Subject: [PATCH 11/12] Added easy on_init feature hook --- map_gen/Diggy/Feature/MarketExchange.lua | 19 ++++++++++++++++--- map_gen/Diggy/Feature/MiningEfficiency.lua | 8 +++----- map_gen/Diggy/Feature/StartingZone.lua | 13 ++++++------- map_gen/Diggy/Scenario.lua | 11 ++++++++--- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/map_gen/Diggy/Feature/MarketExchange.lua b/map_gen/Diggy/Feature/MarketExchange.lua index ffdd29e5..a4ed0754 100644 --- a/map_gen/Diggy/Feature/MarketExchange.lua +++ b/map_gen/Diggy/Feature/MarketExchange.lua @@ -16,6 +16,8 @@ global.MarketExchange = { stone_sent_to_surface = 0, } +local on_init; + --[[-- Registers all event handlers. ]] @@ -35,15 +37,18 @@ function MarketExchange.register(config) end local on_market_timeout_finished = Token.register(function(params) - Template.market(game.surfaces.nauvis, {x = 0, y = -5}, game.forces.player, params.currency_item, params.market_items) + Template.market(params.surface, params.position, params.player_force, params.currency_item, params.market_items) end) - Event.on_init(function() + on_init = function() Task.set_timeout_in_ticks(60, on_market_timeout_finished, { + surface = game.surfaces.nauvis, + position = {x = 0, y = -5}, + player_force = game.forces.player, currency_item = config.currency_item, market_items = market_items, }) - end) + end Event.add(defines.events.on_market_item_purchased, function (event) @@ -59,4 +64,12 @@ function MarketExchange.get_extra_map_info(config) return 'Market Exchange, trade your stone or send it to the surface' end +function MarketExchange.on_init() + if ('function' ~= type(on_init)) then + error('Expected local on_init in MarketExchange to have a function assigned.') + end + + on_init() +end + return MarketExchange diff --git a/map_gen/Diggy/Feature/MiningEfficiency.lua b/map_gen/Diggy/Feature/MiningEfficiency.lua index d96c4f29..1ef9e979 100644 --- a/map_gen/Diggy/Feature/MiningEfficiency.lua +++ b/map_gen/Diggy/Feature/MiningEfficiency.lua @@ -56,10 +56,8 @@ function MiningEfficiency.get_extra_map_info(config) Efficiency increase per level: ]] .. config.mining_speed_productivity_multiplier .. '%' end -Event.on_init( - function() - update_mining_speed(game.forces.player) - end -) +function MiningEfficiency.on_init() + update_mining_speed(game.forces.player) +end return MiningEfficiency diff --git a/map_gen/Diggy/Feature/StartingZone.lua b/map_gen/Diggy/Feature/StartingZone.lua index 1c9922f9..c4ecbf3f 100644 --- a/map_gen/Diggy/Feature/StartingZone.lua +++ b/map_gen/Diggy/Feature/StartingZone.lua @@ -71,13 +71,12 @@ function StartingZone.register(config) daytime = config.daytime end -Event.on_init( - function() - local surface = game.surfaces.nauvis +function StartingZone.on_init() + local surface = game.surfaces.nauvis + + surface.daytime = daytime + surface.freeze_daytime = 1 +end - surface.daytime = daytime - surface.freeze_daytime = 1 - end -) return StartingZone diff --git a/map_gen/Diggy/Scenario.lua b/map_gen/Diggy/Scenario.lua index 701d5b13..fc393184 100644 --- a/map_gen/Diggy/Scenario.lua +++ b/map_gen/Diggy/Scenario.lua @@ -2,6 +2,7 @@ local Config = require 'map_gen.Diggy.Config' local Debug = require 'map_gen.Diggy.Debug' local ScenarioInfo = require 'info' +local Event = require 'utils.event' require 'utils.list_utils' require 'utils.utils' @@ -60,16 +61,20 @@ function Scenario.register(debug) local extra_map_info = '' each_enabled_feature( - function(feature_name, feature_data) + function(feature_name, feature_config) local feature = require ('map_gen.Diggy.Feature.' .. feature_name) if ('function' ~= type(feature.register)) then error('Feature ' .. feature_name .. ' did not define a register function.') end - feature.register(feature_data) + feature.register(feature_config) if ('function' == type(feature.get_extra_map_info)) then - extra_map_info = extra_map_info .. feature.get_extra_map_info(feature_data) .. '\n\n' + extra_map_info = extra_map_info .. feature.get_extra_map_info(feature_config) .. '\n\n' + end + + if ('function' == type(feature.on_init)) then + Event.on_init(feature.on_init) end end ) From 4d0a3b9e7ff49ec65d0ec69d439e456895141f80 Mon Sep 17 00:00:00 2001 From: Lynn Date: Sun, 7 Oct 2018 19:40:30 +0200 Subject: [PATCH 12/12] Tweaked stress values and fixed a bug regarding tile placement --- map_gen/Diggy/Config.lua | 22 ++++----- map_gen/Diggy/Feature/DiggyCaveCollapse.lua | 36 ++++++++------ map_gen/Diggy/Feature/DiggyHole.lua | 49 +++++++++++++------ map_gen/Diggy/Feature/SimpleRoomGenerator.lua | 4 +- map_gen/Diggy/Template.lua | 2 + 5 files changed, 70 insertions(+), 43 deletions(-) diff --git a/map_gen/Diggy/Config.lua b/map_gen/Diggy/Config.lua index e8c60349..e8d4a6e0 100644 --- a/map_gen/Diggy/Config.lua +++ b/map_gen/Diggy/Config.lua @@ -49,25 +49,25 @@ local Config = { mask_relative_ring_weights = {2,3,4}, -- delay in seconds before the cave collapses - collapse_delay_min = 1.5, - collapse_delay_max = 3, + collapse_delay = 2.5, -- the threshold that will be applied to all neighbors on a collapse via a mask collapse_threshold_total_strength = 15, support_beam_entities = { - ['stone-wall'] = 1, - ['sand-rock-big'] = 1, + ['market'] = 9, + ['stone-wall'] = 2.5, + ['sand-rock-big'] = 2, ['out-of-map'] = 1, - ['stone-brick'] = 0.05, - ['stone-path'] = 0.05, - ['concrete'] = 0.1, - ['hazard-concrete-left'] = 0.1, - ['hazard-concrete-right'] = 0.1, - ['refined-concrete'] = 0.1, + ['stone-brick'] = 0.07, + ['stone-path'] = 0.07, + ['concrete'] = 0.11, + ['hazard-concrete-left'] = 0.11, + ['hazard-concrete-right'] = 0.11, + ['refined-concrete'] = 0.15, ['refined-hazard-concrete-left'] = 0.15, ['refined-hazard-concrete-right'] = 0.15, - ['deepwater-green'] = 0.2, + ['deepwater-green'] = 0.7, }, cracking_sounds = { 'CRACK', diff --git a/map_gen/Diggy/Feature/DiggyCaveCollapse.lua b/map_gen/Diggy/Feature/DiggyCaveCollapse.lua index f6e88697..50aa3f2e 100644 --- a/map_gen/Diggy/Feature/DiggyCaveCollapse.lua +++ b/map_gen/Diggy/Feature/DiggyCaveCollapse.lua @@ -32,10 +32,10 @@ local disc_value = 0 local ring_value = 0 local enable_stress_grid = 0 -local stress_map_blur_add = nil -local mask_disc_blur = nil -local stress_map_check_stress_in_threshold = nil -local support_beam_entities = nil +local stress_map_blur_add +local mask_disc_blur +local stress_map_check_stress_in_threshold +local support_beam_entities DiggyCaveCollapse.events = { --[[-- @@ -142,19 +142,23 @@ end local function on_collapse_triggered(event) spawn_cracking_sound_text(event.surface, event.position) Task.set_timeout( - math.random(config.collapse_delay_min * 10, config.collapse_delay_max * 10) / 10, + config.collapse_delay, on_collapse_timeout_finished, {surface = event.surface, position = event.position} ) end -local function on_built_tile(event) - local strength = support_beam_entities[event.item.name] +local function on_built_tile(surface, new_tile, tiles) + local new_tile_strength = support_beam_entities[new_tile.name] - if strength then - local surface = game.surfaces[event.surface_index] - for _, tile in pairs(event.tiles) do - stress_map_blur_add(surface, tile.position, -1 * strength, 'on_built_tile') + for _, tile in pairs(tiles) do + if new_tile_strength then + stress_map_blur_add(surface, tile.position, -1 * new_tile_strength, 'on_built_tile') + end + + local old_tile_strength = support_beam_entities[tile.old_tile.name] + if (old_tile_strength) then + stress_map_blur_add(surface, tile.position, old_tile_strength, 'on_built_tile') end end end @@ -234,8 +238,12 @@ function DiggyCaveCollapse.register(cfg) Event.add(DiggyCaveCollapse.events.on_collapse_triggered, on_collapse_triggered) Event.add(defines.events.on_robot_built_entity, on_built_entity) - Event.add(defines.events.on_robot_built_tile, on_built_tile) - Event.add(defines.events.on_player_built_tile, on_built_tile) + Event.add(defines.events.on_robot_built_tile, function (event) + on_built_tile(event.robot.surface, event.item, event.tiles) + end) + Event.add(defines.events.on_player_built_tile, function (event) + on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles) + end) Event.add(defines.events.on_robot_mined_tile, on_robot_mined_tile) Event.add(defines.events.on_player_mined_tile, on_player_mined_tile) Event.add(defines.events.on_robot_mined_entity, on_mined_entity) @@ -265,7 +273,7 @@ end -- --STRESS MAP -- -local stress_threshold_causing_collapse = 0.9 +local stress_threshold_causing_collapse = 0.91 -- main block global.stress_map_storage = {} diff --git a/map_gen/Diggy/Feature/DiggyHole.lua b/map_gen/Diggy/Feature/DiggyHole.lua index 8a7d2b82..b675a018 100644 --- a/map_gen/Diggy/Feature/DiggyHole.lua +++ b/map_gen/Diggy/Feature/DiggyHole.lua @@ -49,6 +49,31 @@ local artificial_tiles = { ['deepwater-green'] = true, } +local function on_mined_tile(surface, tiles) + local new_tiles = {} + + for _, tile in pairs(tiles) do + if (artificial_tiles[tile.old_tile.name]) then + table.insert(new_tiles, { name = 'dirt-' .. math.random(1, 7), position = tile.position}) + end + end + + Template.insert(surface, new_tiles, {}) +end + +local function on_built_tile(surface, item, old_tile_and_positions) + if ('landfill' ~= item.name) then + return + end + + local tiles = {} + for _, tile in pairs(old_tile_and_positions) do + table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position}) + end + + Template.insert(surface, tiles) +end + --[[-- Registers all event handlers. ]] @@ -68,27 +93,19 @@ function DiggyHole.register(config) end) Event.add(defines.events.on_robot_mined_tile, function(event) - local tiles = {} - - for _, tile in pairs(event.tiles) do - if (artificial_tiles[tile.old_tile.name]) then - table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position}) - end - end - - Template.insert(event.robot.surface, tiles, {}) + on_mined_tile(event.robot.surface, event.tiles) end) Event.add(defines.events.on_player_mined_tile, function(event) - local tiles = {} + on_mined_tile(game.surfaces[event.surface_index], event.tiles) + end) - for _, tile in pairs(event.tiles) do - if (artificial_tiles[tile.old_tile.name]) then - table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position}) - end - end + Event.add(defines.events.on_robot_built_tile, function (event) + on_built_tile(event.robot.surface, item, tiles) + end) - Template.insert(game.surfaces[event.surface_index], tiles, {}) + Event.add(defines.events.on_player_built_tile, function (event) + on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles) end) end diff --git a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua index 5d1cff9f..980ed038 100644 --- a/map_gen/Diggy/Feature/SimpleRoomGenerator.lua +++ b/map_gen/Diggy/Feature/SimpleRoomGenerator.lua @@ -34,8 +34,8 @@ local function handle_noise(name, surface, position) Task.set_timeout_in_ticks(1, do_mine, {surface = surface, position = position}) if ('water' == name) then - -- water is lower because for some odd reason it doesn't always want to mine it properly - Task.set_timeout_in_ticks(5, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}}) + -- water is slower because for some odd reason it doesn't always want to mine it properly + Task.set_timeout_in_ticks(3, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}}) return end diff --git a/map_gen/Diggy/Template.lua b/map_gen/Diggy/Template.lua index 895af2ee..48c07beb 100644 --- a/map_gen/Diggy/Template.lua +++ b/map_gen/Diggy/Template.lua @@ -215,6 +215,8 @@ function Template.market(surface, position, force, currency_item, market_invento text = ' Market', position = position, }) + + script.raise_event(Template.events.on_placed_entity, {entity = market}) end return Template