From 9ac3f0a37011426f7c3793ebdb9a2cc89467630a Mon Sep 17 00:00:00 2001 From: Rdjrjqouqcu Date: Fri, 16 Nov 2018 20:55:42 -0500 Subject: [PATCH] Seperated the configs to be defined in a different file, reducing the length of the main config file --- map_gen/Diggy/Config.lua | 275 +------------------ map_gen/Diggy/Feature/ScatteredResources.lua | 5 +- map_gen/Diggy/Orepattern/Clusters.lua | 51 ++++ map_gen/Diggy/Orepattern/Tendrils.lua | 221 +++++++++++++++ 4 files changed, 279 insertions(+), 273 deletions(-) create mode 100644 map_gen/Diggy/Orepattern/Clusters.lua create mode 100644 map_gen/Diggy/Orepattern/Tendrils.lua diff --git a/map_gen/Diggy/Config.lua b/map_gen/Diggy/Config.lua index 4143f2b5..cd0fd52b 100644 --- a/map_gen/Diggy/Config.lua +++ b/map_gen/Diggy/Config.lua @@ -266,279 +266,10 @@ local Config = { -- creates compound clusters of ores defined by a layered ore-gen cluster_mode = true, - -- in compound cluster mode, final ore quantities are generated by the following procedure: - -- iterate through each cluster checking the following conditions - -- if the distance < min_distance, check the next cluster - -- if the noise value < threshold, check the next cluster - -- a resource_type is generated based on the values of weights - -- if resource_type is 'skip', check the next cluster - -- if an entry in distances exists for the given resource_type - -- if distance < distances[resource_type], check the next cluster - -- a range of values is selected from richness_values based on richness_weights - -- base_amount = a random value from within the selected range of values - -- amount is multiplied by cluster yield - -- amount is multiplied by 1 + 0.01*(distance / distance_richness) - -- this means every distance_richness tiles, the quantity increases by 1% - -- if the resource_type has an entry in the type_scalar - -- then the amount is multiplied by the scalar - -- the resource is then generated and no further clusters are checked + -- location of file to find the cluster definition file + cluster_file_location = 'map_gen.Diggy.Orepattern.Tendrils', + --cluster_file_location = 'map_gen.Diggy.Orepattern.Clusters', - - -- defines all ore patches to be generated. Add as many clusters as - -- needed. Clusters listed first have a higher placement priority over - -- the latter clusters - -- - -- noise types: - -- cluster: same as vanilla factorio generation - -- skip: skips this cluster - -- connected_tendril: long ribbons of ore - -- fragmented_tendril: long ribbons of ore that occur when inside another - -- region of ribbons - -- - -- noise source types and configurations - -- perlin: same as vanilla factorio generation - -- variance: increase to make patches closer together and smaller - -- note that this is the inverse of the cluster_mode variance - -- threshold: increase to shrink size of patches - -- simplex: similar to perlin - -- zero: does nothing with this source - -- one: adds the weight directly to the noise calculation - clusters = { - -- start the next line with 3 dashes to enable default single cluster mode - -- or with 2 dashes to disable it - - --[[ Single clusters - { - yield=1.0, - min_distance=30, - distance_richness=7, - noise_settings = { - type = "cluster", - threshold = 0.40, - sources = { - {variance=25, weight = 1, offset = 000, type="perlin"}, - } - }, - weights = { - ['coal'] = 160, - ['copper-ore'] = 215, - ['iron-ore'] = 389, - ['stone'] = 212, - ['uranium-ore'] = 21, - ['crude-oil'] = 3, - }, - distances = { - ['coal'] = 16, - ['copper-ore'] = 18, - ['iron-ore'] = 18, - ['stone'] = 15, - ['uranium-ore'] = 86, - ['crude-oil'] = 57, - }, }, - --]] - - -- start the next line with 3 dashes to enable default tendril mode - -- or with 2 dashes to disable it - - ---[[ Tendril clusters - { -- tendril default large - yield=1.5, - min_distance=30, - distance_richness=7, - color={r=255/255, g=0/255, b=255/255}, - noise_settings = { - type = "connected_tendril", - threshold = 0.05, - sources = { - {variance=350*2, weight = 1.000, offset = 000, type="simplex"}, - {variance=200*2, weight = 0.350, offset = 150, type="simplex"}, - {variance=050*2, weight = 0.050, offset = 300, type="simplex"}, - {variance=020*2, weight = 0.015, offset = 450, type="simplex"}, - } - }, - weights = { - ['coal'] = 160, - ['copper-ore'] = 215, - ['iron-ore'] = 389, - ['stone'] = 212, - ['uranium-ore'] = 21, - }, - distances = { - ['coal'] = 16, - ['copper-ore'] = 18, - ['iron-ore'] = 18, - ['stone'] = 15, - ['uranium-ore'] = 86, - }, }, - { -- tendril default small - yield=1.0, - min_distance=30, - distance_richness=7, - color={r=255/255, g=255/255, b=0/255}, - noise_settings = { - type = "connected_tendril", - threshold = 0.05, - sources = { - {variance=120, weight = 1.000, offset = 000, type="simplex"}, - {variance=060, weight = 0.300, offset = 150, type="simplex"}, - {variance=040, weight = 0.200, offset = 300, type="simplex"}, - {variance=020, weight = 0.090, offset = 450, type="simplex"}, - } - }, - weights = { - ['coal'] = 160, - ['copper-ore'] = 215, - ['iron-ore'] = 389, - ['stone'] = 212, - ['uranium-ore'] = 21, - }, - distances = { - ['coal'] = 16, - ['copper-ore'] = 18, - ['iron-ore'] = 18, - ['stone'] = 15, - ['uranium-ore'] = 86, - }, - }, - { -- tendril default fragments coal - yield=0.25, - min_distance=30, - distance_richness=7, - color={r=0/255, g=0/255, b=0/255}, - noise_settings = { - type = "fragmented_tendril", - threshold = 0.05, - discriminator_threshold = 0.4, - sources = { - {variance=050, weight = 1.000, offset = 600, type="simplex"}, - {variance=030, weight = 0.500, offset = 750, type="simplex"}, - {variance=020, weight = 0.250, offset = 900, type="simplex"}, - {variance=010, weight = 0.100, offset =1050, type="simplex"}, - }, - discriminator = { - {variance=120, weight = 1.000, offset = 000, type="simplex"}, - {variance=060, weight = 0.300, offset = 150, type="simplex"}, - {variance=040, weight = 0.200, offset = 300, type="simplex"}, - {variance=020, weight = 0.090, offset = 450, type="simplex"}, - }, - }, - weights = { - ['coal'] = 1, - }, - distances = { - ['coal'] = 16, - }, - }, - { -- tendril default fragments iron - yield=0.25, - min_distance=30, - distance_richness=7, - color={r=0/255, g=140/255, b=255/255}, - noise_settings = { - type = "fragmented_tendril", - threshold = 0.05, - discriminator_threshold = 0.4, - sources = { - {variance=050, weight = 1.000, offset = 600, type="simplex"}, - {variance=030, weight = 0.500, offset = 750, type="simplex"}, - {variance=020, weight = 0.250, offset = 900, type="simplex"}, - {variance=010, weight = 0.100, offset =1050, type="simplex"}, - }, - discriminator = { - {variance=120, weight = 1.000, offset = 000, type="simplex"}, - {variance=060, weight = 0.300, offset = 150, type="simplex"}, - {variance=040, weight = 0.200, offset = 300, type="simplex"}, - {variance=020, weight = 0.090, offset = 450, type="simplex"}, - }, - }, - weights = { - ['iron-ore'] = 389, - }, - distances = { - ['coal'] = 16, - ['iron-ore'] = 18, - }, - }, - { -- tendril default fragments copper - yield=0.25, - min_distance=30, - distance_richness=7, - color={r=255/255, g=55/255, b=0/255}, - noise_settings = { - type = "fragmented_tendril", - threshold = 0.05, - discriminator_threshold = 0.4, - sources = { - {variance=050, weight = 1.000, offset = 600, type="simplex"}, - {variance=030, weight = 0.500, offset = 750, type="simplex"}, - {variance=020, weight = 0.250, offset = 900, type="simplex"}, - {variance=010, weight = 0.100, offset =1050, type="simplex"}, - }, - discriminator = { - {variance=120, weight = 1.000, offset = 000, type="simplex"}, - {variance=060, weight = 0.300, offset = 150, type="simplex"}, - {variance=040, weight = 0.200, offset = 300, type="simplex"}, - {variance=020, weight = 0.090, offset = 450, type="simplex"}, - }, - }, - weights = { - ['copper-ore'] = 215, - }, - distances = { - ['copper-ore'] = 18, - }, - }, - { -- tendril default fragments stone - yield=0.25, - min_distance=30, - distance_richness=7, - color={r=100/255, g=100/255, b=100/255}, - noise_settings = { - type = "fragmented_tendril", - threshold = 0.05, - discriminator_threshold = 0.4, - sources = { - {variance=050, weight = 1.000, offset = 600, type="simplex"}, - {variance=030, weight = 0.500, offset = 750, type="simplex"}, - {variance=020, weight = 0.250, offset = 900, type="simplex"}, - {variance=010, weight = 0.100, offset =1050, type="simplex"}, - }, - discriminator = { - {variance=120, weight = 1.000, offset = 000, type="simplex"}, - {variance=060, weight = 0.300, offset = 150, type="simplex"}, - {variance=040, weight = 0.200, offset = 300, type="simplex"}, - {variance=020, weight = 0.090, offset = 450, type="simplex"}, - }, - }, - weights = { - ['stone'] = 1, - }, - distances = { - ['stone'] = 15, - }, - }, - { -- crude oil - yield=1.7, - min_distance=57, - distance_richness=7, - color={r=0/255, g=255/255, b=255/255}, - noise_settings = { - type = "cluster", - threshold = 0.40, - sources = { - {variance=25, weight = 1, offset = 000, type="perlin"}, - }, - }, - weights = { - ['skip'] = 997, - ['crude-oil'] = 3, - }, - distances = { - ['crude-oil'] = 57, - }, - }, - --]] - }, }, -- controls the alien spawning mechanic diff --git a/map_gen/Diggy/Feature/ScatteredResources.lua b/map_gen/Diggy/Feature/ScatteredResources.lua index d6964b05..4abd730e 100644 --- a/map_gen/Diggy/Feature/ScatteredResources.lua +++ b/map_gen/Diggy/Feature/ScatteredResources.lua @@ -96,7 +96,10 @@ function ScatteredResources.register(config) -- compound cluster spawning local c_mode = config.cluster_mode - local c_clusters = config.clusters + local c_clusters = require(config.cluster_file_location) + if ('table' ~= type(c_clusters)) then + error('cluster_file_location invalid') + end local c_count = 0 for _, cluster in ipairs(c_clusters) do c_count = c_count + 1 diff --git a/map_gen/Diggy/Orepattern/Clusters.lua b/map_gen/Diggy/Orepattern/Clusters.lua new file mode 100644 index 00000000..1bf197dd --- /dev/null +++ b/map_gen/Diggy/Orepattern/Clusters.lua @@ -0,0 +1,51 @@ + +-- defines all ore patches to be generated. Add as many clusters as +-- needed. Clusters listed first have a higher placement priority over +-- the latter clusters +-- +-- TODO update and document all configuration settings +-- +-- noise types: +-- cluster: same as vanilla factorio generation +-- skip: skips this cluster +-- connected_tendril: long ribbons of ore +-- fragmented_tendril: long ribbons of ore that occur when inside another +-- region of ribbons +-- +-- noise source types and configurations +-- perlin: same as vanilla factorio generation +-- variance: increase to make patches closer together and smaller +-- note that this is the inverse of the cluster_mode variance +-- threshold: increase to shrink size of patches +-- simplex: similar to perlin +-- zero: does nothing with this source +-- one: adds the weight directly to the noise calculation +clusters = { + { + yield=1.0, + min_distance=30, + distance_richness=7, + noise_settings = { + type = "cluster", + threshold = 0.40, + sources = { + {variance=25, weight = 1, offset = 000, type="perlin"}, + } + }, + weights = { + ['coal'] = 160, + ['copper-ore'] = 215, + ['iron-ore'] = 389, + ['stone'] = 212, + ['uranium-ore'] = 21, + ['crude-oil'] = 3, + }, + distances = { + ['coal'] = 16, + ['copper-ore'] = 18, + ['iron-ore'] = 18, + ['stone'] = 15, + ['uranium-ore'] = 86, + ['crude-oil'] = 57, + }, }, +} \ No newline at end of file diff --git a/map_gen/Diggy/Orepattern/Tendrils.lua b/map_gen/Diggy/Orepattern/Tendrils.lua new file mode 100644 index 00000000..c4951ec6 --- /dev/null +++ b/map_gen/Diggy/Orepattern/Tendrils.lua @@ -0,0 +1,221 @@ + +-- defines all ore patches to be generated. Add as many clusters as +-- needed. Clusters listed first have a higher placement priority over +-- the latter clusters +-- +-- TODO update and document all configuration settings +-- +-- noise types: +-- cluster: same as vanilla factorio generation +-- skip: skips this cluster +-- connected_tendril: long ribbons of ore +-- fragmented_tendril: long ribbons of ore that occur when inside another +-- region of ribbons +-- +-- noise source types and configurations +-- perlin: same as vanilla factorio generation +-- variance: increase to make patches closer together and smaller +-- note that this is the inverse of the cluster_mode variance +-- threshold: increase to shrink size of patches +-- simplex: similar to perlin +-- zero: does nothing with this source +-- one: adds the weight directly to the noise calculation + +return { + { -- tendril default large + yield=1.5, + min_distance=30, + distance_richness=7, + color={r=255/255, g=0/255, b=255/255}, + noise_settings = { + type = "connected_tendril", + threshold = 0.05, + sources = { + {variance=350*2, weight = 1.000, offset = 000, type="simplex"}, + {variance=200*2, weight = 0.350, offset = 150, type="simplex"}, + {variance=050*2, weight = 0.050, offset = 300, type="simplex"}, + {variance=020*2, weight = 0.015, offset = 450, type="simplex"}, + } + }, + weights = { + ['coal'] = 160, + ['copper-ore'] = 215, + ['iron-ore'] = 389, + ['stone'] = 212, + ['uranium-ore'] = 21, + }, + distances = { + ['coal'] = 16, + ['copper-ore'] = 18, + ['iron-ore'] = 18, + ['stone'] = 15, + ['uranium-ore'] = 86, + }, }, + { -- tendril default small + yield=1.0, + min_distance=30, + distance_richness=7, + color={r=255/255, g=255/255, b=0/255}, + noise_settings = { + type = "connected_tendril", + threshold = 0.05, + sources = { + {variance=120, weight = 1.000, offset = 000, type="simplex"}, + {variance=060, weight = 0.300, offset = 150, type="simplex"}, + {variance=040, weight = 0.200, offset = 300, type="simplex"}, + {variance=020, weight = 0.090, offset = 450, type="simplex"}, + } + }, + weights = { + ['coal'] = 160, + ['copper-ore'] = 215, + ['iron-ore'] = 389, + ['stone'] = 212, + ['uranium-ore'] = 21, + }, + distances = { + ['coal'] = 16, + ['copper-ore'] = 18, + ['iron-ore'] = 18, + ['stone'] = 15, + ['uranium-ore'] = 86, + }, + }, + { -- tendril default fragments coal + yield=0.25, + min_distance=30, + distance_richness=7, + color={r=0/255, g=0/255, b=0/255}, + noise_settings = { + type = "fragmented_tendril", + threshold = 0.05, + discriminator_threshold = 0.4, + sources = { + {variance=050, weight = 1.000, offset = 600, type="simplex"}, + {variance=030, weight = 0.500, offset = 750, type="simplex"}, + {variance=020, weight = 0.250, offset = 900, type="simplex"}, + {variance=010, weight = 0.100, offset =1050, type="simplex"}, + }, + discriminator = { + {variance=120, weight = 1.000, offset = 000, type="simplex"}, + {variance=060, weight = 0.300, offset = 150, type="simplex"}, + {variance=040, weight = 0.200, offset = 300, type="simplex"}, + {variance=020, weight = 0.090, offset = 450, type="simplex"}, + }, + }, + weights = { + ['coal'] = 1, + }, + distances = { + ['coal'] = 16, + }, + }, + { -- tendril default fragments iron + yield=0.25, + min_distance=30, + distance_richness=7, + color={r=0/255, g=140/255, b=255/255}, + noise_settings = { + type = "fragmented_tendril", + threshold = 0.05, + discriminator_threshold = 0.4, + sources = { + {variance=050, weight = 1.000, offset = 600, type="simplex"}, + {variance=030, weight = 0.500, offset = 750, type="simplex"}, + {variance=020, weight = 0.250, offset = 900, type="simplex"}, + {variance=010, weight = 0.100, offset =1050, type="simplex"}, + }, + discriminator = { + {variance=120, weight = 1.000, offset = 000, type="simplex"}, + {variance=060, weight = 0.300, offset = 150, type="simplex"}, + {variance=040, weight = 0.200, offset = 300, type="simplex"}, + {variance=020, weight = 0.090, offset = 450, type="simplex"}, + }, + }, + weights = { + ['iron-ore'] = 389, + }, + distances = { + ['coal'] = 16, + ['iron-ore'] = 18, + }, + }, + { -- tendril default fragments copper + yield=0.25, + min_distance=30, + distance_richness=7, + color={r=255/255, g=55/255, b=0/255}, + noise_settings = { + type = "fragmented_tendril", + threshold = 0.05, + discriminator_threshold = 0.4, + sources = { + {variance=050, weight = 1.000, offset = 600, type="simplex"}, + {variance=030, weight = 0.500, offset = 750, type="simplex"}, + {variance=020, weight = 0.250, offset = 900, type="simplex"}, + {variance=010, weight = 0.100, offset =1050, type="simplex"}, + }, + discriminator = { + {variance=120, weight = 1.000, offset = 000, type="simplex"}, + {variance=060, weight = 0.300, offset = 150, type="simplex"}, + {variance=040, weight = 0.200, offset = 300, type="simplex"}, + {variance=020, weight = 0.090, offset = 450, type="simplex"}, + }, + }, + weights = { + ['copper-ore'] = 215, + }, + distances = { + ['copper-ore'] = 18, + }, + }, + { -- tendril default fragments stone + yield=0.25, + min_distance=30, + distance_richness=7, + color={r=100/255, g=100/255, b=100/255}, + noise_settings = { + type = "fragmented_tendril", + threshold = 0.05, + discriminator_threshold = 0.4, + sources = { + {variance=050, weight = 1.000, offset = 600, type="simplex"}, + {variance=030, weight = 0.500, offset = 750, type="simplex"}, + {variance=020, weight = 0.250, offset = 900, type="simplex"}, + {variance=010, weight = 0.100, offset =1050, type="simplex"}, + }, + discriminator = { + {variance=120, weight = 1.000, offset = 000, type="simplex"}, + {variance=060, weight = 0.300, offset = 150, type="simplex"}, + {variance=040, weight = 0.200, offset = 300, type="simplex"}, + {variance=020, weight = 0.090, offset = 450, type="simplex"}, + }, + }, + weights = { + ['stone'] = 1, + }, + distances = { + ['stone'] = 15, + }, + }, + { -- crude oil + yield=1.7, + min_distance=57, + distance_richness=7, + color={r=0/255, g=255/255, b=255/255}, + noise_settings = { + type = "cluster", + threshold = 0.40, + sources = { + {variance=25, weight = 1, offset = 000, type="perlin"}, + }, + }, + weights = { + ['skip'] = 997, + ['crude-oil'] = 3, + }, + distances = { + ['crude-oil'] = 57, + }, + }, +} \ No newline at end of file