diff --git a/map_gen/maps/diggy.lua b/map_gen/maps/diggy.lua index 16318f3f..a6c42253 100644 --- a/map_gen/maps/diggy.lua +++ b/map_gen/maps/diggy.lua @@ -1,2 +1,2 @@ -- authors Linaori, valansch -require 'map_gen.maps.diggy.scenario'.register() +require 'map_gen.maps.diggy.presets.normal' diff --git a/map_gen/maps/diggy/feature/danger_ore.lua b/map_gen/maps/diggy/feature/danger_ore.lua new file mode 100644 index 00000000..81460540 --- /dev/null +++ b/map_gen/maps/diggy/feature/danger_ore.lua @@ -0,0 +1,52 @@ +-- This module prevents all but the allowed items from being built on top of resources +local RestrictEntities = require 'map_gen.shared.entity_placement_restriction' +local Event = require 'utils.event' +local Token = require 'utils.token' +local ScenarioInfo = require 'features.gui.info' + +local DangerOre = {} + +local function banned_entities(allowed_entities) + --- Items explicitly allowed on ores + RestrictEntities.add_allowed(allowed_entities) + + --- The logic for checking that there are resources under the entity's position + RestrictEntities.set_keep_alive_callback( + Token.register( + function(entity) + -- Some entities have a bounding_box area of zero, eg robots. + local area = entity.bounding_box + local left_top, right_bottom = area.left_top, area.right_bottom + if left_top.x == right_bottom.x and left_top.y == right_bottom.y then + return true + end + local count = entity.surface.count_entities_filtered {area = area, type = 'resource', limit = 1} + if count == 0 then + return true + end + end + ) + ) + + --- Warning for players when their entities are destroyed + local function on_destroy(event) + local p = event.player + if p and p.valid then + p.print('You cannot build that on top of ores, only belts, mining drills, and power poles are allowed.') + end + end + + Event.add(RestrictEntities.events.on_restricted_entity_destroyed, on_destroy) +end + +function DangerOre.register (config) + local allowed_entities = config.allowed_entities + banned_entities(allowed_entities) + ScenarioInfo.add_map_extra_info([[Danger! Ores are generally unstable to build upon. +Only the following entities have been strengthened for building upon the ores: + [item=burner-mining-drill] [item=electric-mining-drill] [item=pumpjack] [item=small-electric-pole] [item=medium-electric-pole] [item=big-electric-pole] [item=substation] [item=car] [item=tank] [item=spidertron] + [item=stone-wall][item=small-lamp][item=transport-belt] [item=fast-transport-belt] [item=express-transport-belt] [item=underground-belt] [item=fast-underground-belt] [item=express-underground-belt] [item=stone-wall] [item=small-lamp] +]]) +end + +return DangerOre diff --git a/map_gen/maps/diggy/presets/danger_ores.lua b/map_gen/maps/diggy/presets/danger_ores.lua new file mode 100644 index 00000000..f8bda022 --- /dev/null +++ b/map_gen/maps/diggy/presets/danger_ores.lua @@ -0,0 +1,482 @@ +-- dependencies +local ScenarioInfo = require 'features.gui.info' +local abs = math.abs + +local config = { + scenario_name = 'diggy-danger-ores', + -- a list of features to register and enable + -- to disable a feature, change the flag + features = { + -- creates a starting zone + starting_zone = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.starting_zone') end, + -- initial starting position size, higher values are not recommended + starting_size = 8, + -- where the market should spawn + market_spawn_position = {x = 0, y = 3} + }, + -- controls the Daylight (Default diggy: enabled = true) + night_time = { + enabled = true, -- true = No Daylight, false = Day/night circle (Solar panels work) + load = function() return require('map_gen.maps.diggy.feature.night_time') end + }, + -- controls setting up the players + setup_player = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.setup_player') end, + starting_items = { + {name = 'stone-wall', count = 12}, + {name = 'iron-gear-wheel', count = 8}, + {name = 'iron-plate', count = 16} + }, + + -- 0.01 bonus equals 1% in game. This value is recommended to be tweaked for single player + initial_mining_speed_bonus = 1, + + -- applied when _CHEATS is set to true and _DEBUG is NOT true. + -- see config.lua -> config.player_create.cheats for available options + cheats = { + enabled = true, + -- Sets the manual mining speed for the player force. A value of 1 = 100% faster. Setting it + -- to 0.5 would make it 50% faster than the base speed. + manual_mining_speed_modifier = 1000, + -- increase the amount of inventory slots for the player force + character_inventory_slots_bonus = 0, + -- increases the run speed of all characters for the player force + character_running_speed_modifier = 2, + -- a flat health bonus to the player force + character_health_bonus = 1000000, + -- starts with a fully slotted power armor mk2 + start_with_power_armor = true, + -- adds additional items to the player force when starting in addition to defined in start_items above + starting_items = {} + } + }, + -- controls the introduction cutscene + cutscene = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.cutscene') end + }, + -- core feature + diggy_hole = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.diggy_hole') end, + -- delay in ticks between robot mining rock and rock being marked again for deconstruction + robot_mining_delay = 6, + -- This value is multiplied with robot_mining_delay to determine mining damage applied. Can be enhanced by robot_damage_per_mining_prod_level + robot_per_tick_damage = 4, + -- damage added per level of mining productivity level research + robot_damage_per_mining_prod_level = 1, + + -- turn this setting on if you want to bring back landfill research, default is off due to griefing + allow_landfill_research = false, + }, + -- adds the ability to collapse caves + diggy_cave_collapse = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.diggy_cave_collapse') end, + -- adds per tile what the current stress is + enable_stress_grid = false, + -- shows the mask on spawn + enable_mask_debug = false, + --the size of the mask used + mask_size = 9, + --how much the mask will effect tiles in the different rings of the mask + mask_relative_ring_weights = {2, 3, 4}, + -- delay in seconds before the cave collapses + collapse_delay = 2.5, + -- the threshold that will be applied to all neighbors on a collapse via a mask + collapse_threshold_total_strength = 16, + support_beam_entities = { + ['market'] = 9, + ['nuclear-reactor'] = 4, + ['stone-wall'] = 3, + ['sand-rock-big'] = 2, + ['rock-big'] = 2, + ['rock-huge'] = 2.5, + ['out-of-map'] = 1, + ['stone-path'] = 0.03, + ['concrete'] = 0.04, + ['hazard-concrete'] = 0.04, + ['refined-concrete'] = 0.06, + ['refined-hazard-concrete'] = 0.06 + }, + cracking_sounds = { + {'diggy.cracking_sound_1'}, + {'diggy.cracking_sound_2'} + } + }, + -- Adds the ability to drop coins and track how many are sent into space + coin_gathering = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.coin_gathering') end, + -- value between 0 and 1, higher value means stronger variance between coordinates + noise_variance = 0.75, + -- minimum noise value to spawn a treasure chest, works best with a very high noise variance, + -- otherwise you risk spawning a lot of chests together + treasure_chest_noise_threshold = 0.69, + -- minimum distance from spawn where a chest can spawn + minimal_treasure_chest_distance = 25, + -- chances to receive a coin when mining + mining_coin_chance = 0.15, + mining_coin_amount = {min = 1, max = 5}, + -- lets you set the coin modifiers for aliens + -- the modifier value increases the upper random limit that biters can drop + alien_coin_modifiers = { + ['small-biter'] = 2, + ['small-spitter'] = 2, + ['small-worm-turret'] = 2, + ['medium-biter'] = 3, + ['medium-spitter'] = 3, + ['medium-worm-turret'] = 3, + ['big-biter'] = 5, + ['big-spitter'] = 5, + ['big-worm-turret'] = 5, + ['behemoth-biter'] = 7, + ['behemoth-spitter'] = 7 + }, + -- chance of aliens dropping coins between 0 and 1, where 1 is 100% + alien_coin_drop_chance = 0.28, + -- shows the chest locations, only use when debugging + display_chest_locations = false, + treasure_chest_raffle = { + ['coin'] = {chance = 1.00, min = 20, max = 255}, + ['stone'] = {chance = 0.20, min = 15, max = 40}, + ['copper-ore'] = {chance = 0.25, min = 30, max = 60}, + ['copper-plate'] = {chance = 0.10, min = 12, max = 25}, + ['iron-ore'] = {chance = 0.20, min = 10, max = 55}, + ['iron-plate'] = {chance = 0.10, min = 5, max = 25}, + ['steel-plate'] = {chance = 0.05, min = 3, max = 14}, + ['steel-furnace'] = {chance = 0.03, min = 1, max = 2}, + ['steam-engine'] = {chance = 0.03, min = 1, max = 2}, + ['coal'] = {chance = 0.30, min = 30, max = 55}, + ['concrete'] = {chance = 0.14, min = 10, max = 50}, + ['stone-brick'] = {chance = 0.14, min = 25, max = 75}, + ['stone-wall'] = {chance = 0.50, min = 1, max = 5}, + ['transport-belt'] = {chance = 0.10, min = 1, max = 5}, + ['fast-transport-belt'] = {chance = 0.07, min = 2, max = 7}, + ['express-transport-belt'] = {chance = 0.04, min = 4, max = 9}, + ['rail'] = {chance = 0.20, min = 7, max = 15}, + ['rail-signal'] = {chance = 0.05, min = 3, max = 8}, + ['rail-chain-signal'] = {chance = 0.05, min = 3, max = 8}, + ['firearm-magazine'] = {chance = 0.25, min = 35, max = 120}, + ['piercing-rounds-magazine'] = {chance = 0.10, min = 15, max = 35}, + ['gun-turret'] = {chance = 0.3, min = 1, max = 2}, + ['beacon'] = {chance = 0.01, min = 1, max = 2}, + ['effectivity-module'] = {chance = 0.03, min = 1, max = 2}, + ['effectivity-module-2'] = {chance = 0.01, min = 1, max = 2}, + ['productivity-module'] = {chance = 0.03, min = 1, max = 2}, + ['productivity-module-2'] = {chance = 0.01, min = 1, max = 2}, + ['speed-module'] = {chance = 0.03, min = 1, max = 2}, + ['speed-module-2'] = {chance = 0.01, min = 1, max = 2}, + ['small-lamp'] = {chance = 0.05, min = 1, max = 5} + } + }, + -- replaces the chunks with void + refresh_map = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.refresh_map') end + }, + -- automatically opens areas + simple_room_generator = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.simple_room_generator') end, + -- value between 0 and 1, higher value means stronger variance between coordinates + noise_variance = 0.066, + -- shows where rooms are located + display_room_locations = false, + -- minimum distance and noise range required for water to spawn + room_noise_minimum_distance = 9, + room_noise_ranges = { + {name = 'water', min = 0.54, max = 1}, + {name = 'dirt', min = 0.37, max = 0.54} + } + }, + -- responsible for resource spawning + scattered_resources = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.scattered_resources') end, + -- determines how distance is measured + distance = function(x, y) + return abs(x) + abs(y) + end, + --distance = function (x, y) return math.sqrt(x * x + y * y) end, + + -- defines the weights of which resource_richness_value to spawn + resource_richness_weights = { + ['scarce'] = 440, + ['low'] = 350, + ['sufficient'] = 164, + ['good'] = 30, + ['plenty'] = 10, + ['jackpot'] = 6 + }, + -- defines the min and max range of ores to spawn + resource_richness_values = { + ['scarce'] = {1, 200}, + ['low'] = {201, 400}, + ['sufficient'] = {401, 750}, + ['good'] = {751, 1200}, + ['plenty'] = {1201, 2000}, + ['jackpot'] = {2001, 5000} + }, + -- increases the amount of resources by flat multiplication to initial amount + -- highly suggested to use for fluids so their yield is reasonable + resource_type_scalar = { + ['crude-oil'] = 1500, + ['uranium-ore'] = 1.25 + }, + -- ============== + -- Debug settings + -- ============== + + -- shows the ore locations, only use when debugging (compound_cluster_mode) + display_ore_clusters = false, + -- ======================= + -- Scattered mode settings + -- ======================= + + -- creates scattered ore (single tiles) at random locations + scattered_mode = false, + -- defines the increased chance of spawning resources + -- calculated_probability = resource_probability + ((distance / scattered_distance_probability_modifier) / 100) + -- this means the chance increases by 1% every DISTANCE tiles up to the max_probability + scattered_distance_probability_modifier = 10, + -- min percentage of chance that resources will spawn after mining + scattered_min_probability = 0.01, + -- max chance of spawning resources based on resource_probability + calculated scattered_distance_probability_modifier + scattered_max_probability = 0.10, + -- percentage of resource added to the sum. 100 tiles means + -- 10% more resources with a distance_richness_modifier of 10 + -- 20% more resources with a distance_richness_modifier of 5 + scattered_distance_richness_modifier = 7, + -- multiplies probability only if cluster mode is enabled + scattered_cluster_probability_multiplier = 0.5, + -- multiplies yield only if cluster mode is enabled + scattered_cluster_yield_multiplier = 1.7, + -- weights per resource of spawning + scattered_resource_weights = { + ['coal'] = 160, + ['copper-ore'] = 215, + ['iron-ore'] = 389, + ['stone'] = 212, + ['uranium-ore'] = 21, + ['crude-oil'] = 3 + }, + -- minimum distance from the spawn point required before it spawns + scattered_minimum_resource_distance = { + ['coal'] = 16, + ['copper-ore'] = 18, + ['iron-ore'] = 18, + ['stone'] = 15, + ['uranium-ore'] = 86, + ['crude-oil'] = 57 + }, + -- ============================== + -- Compound cluster mode settings + -- ============================== + + -- creates compound clusters of ores defined by a layered ore-gen + cluster_mode = true, + -- spawns tendrils of ore with roughly 80% purity + --ore_pattern = require 'map_gen.maps.diggy.orepattern.tendrils_impure' + + -- spawns some smaller dedicated and bigger mixed tendrils + --ore_pattern = require 'map_gen.maps.diggy.orepattern.tendrils', + + -- spawns clusters of ore similar to vanilla, but mixed + ore_pattern = require 'map_gen.maps.diggy.orepattern.clusters', + }, + -- controls the alien spawning mechanic + alien_spawner = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.alien_spawner') end, + + -- minimum distance from spawn before aliens can spawn + alien_minimum_distance = 40, + + -- chance of spawning aliens when mining from 0 to 1 + alien_probability = 0.05, + + -- each tile of void removed increases alien evolution by + evolution_per_void_removed = 0.0000024, + + -- initial evolution percentage, recommended to set to 0 for non-multiplayer setups + initial_evolution = 10, + + -- evolution over time value, leave nil to use vanilla settings + evolution_over_time_factor = 0.000006, + + -- spawns the following units when they die. To disable, remove the contents + -- any non-rounded number will turn into a chance to spawn an additional alien + -- example: 2.5 would spawn 2 for sure and 50% chance to spawn one additionally + hail_hydra = { + -- spitters + ['small-spitter'] = {['small-worm-turret'] = {min = 0.1, max = 0.8}}, + ['medium-spitter'] = {['medium-worm-turret'] = {min = 0.1, max = 0.8}}, + ['big-spitter'] = {['big-worm-turret'] = {min = 0.1, max = 0.8}}, + ['behemoth-spitter'] = {['behemoth-worm-turret'] = {min = 0.2, max = 0.8}}, + -- biters + ['medium-biter'] = {['small-biter'] = {min = 0.6, max = 1.5}}, + ['big-biter'] = {['medium-biter'] = {min = 0.6, max = 1.5}}, + ['behemoth-biter'] = {['big-biter'] = {min = 0.6, max = 2}}, + -- worms + ['small-worm-turret'] = {['small-biter'] = {min = 1, max = 2.5}}, + ['medium-worm-turret'] = { + ['small-biter'] = {min = 1, max = 2.5}, + ['medium-biter'] = {min = 0.3, max = 1.5} + }, + ['big-worm-turret'] = { + ['small-biter'] = {min = 1, max = 2.5}, + ['medium-biter'] = {min = 0.7, max = 1.5}, + ['big-biter'] = {min = 0.7, max = 2} + }, + ['behemoth-worm-turret'] = { + ['small-biter'] = {min = 1.5, max = 3}, + ['medium-biter'] = {min = 1.2, max = 2}, + ['big-biter'] = {min = 1, max = 2}, + ['behemoth-biter'] = {min = 0.7, max = 1.2} + } + } + }, + --Tracks players causing collapses + antigrief = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.antigrief') end, + autojail = true, + allowed_collapses_first_hour = 4 + }, + experience = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.experience') end, + -- controls the formula for calculating level up costs in stone sent to surface + difficulty_scale = 20, -- Diggy default 15. Higher increases experience requirement climb + first_lvl_xp = 350, -- Diggy default 350. This sets the price for the first level. + xp_fine_tune = 400, -- Diggy default 200. This value is used to fine tune the overall requirement climb without affecting the speed + cost_precision = 3, -- Diggy default 3. This sets the precision of the required experience to level up. E.g. 1234 becomes 1200 with precision 2 and 1230 with precision 3. + -- percentage * mining productivity level gets added to mining speed + mining_speed_productivity_multiplier = 5, + XP = { + ['sand-rock-big'] = 5, + ['rock-big'] = 5, + ['rock-huge'] = 10, + ['rocket_launch'] = 0.05, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.05 which equals 5%) + ['rocket_launch_max'] = 500000, -- Max XP reward from rocket launches (Diggy default: 500000) + ['automation-science-pack'] = 4, + ['logistic-science-pack'] = 8, + ['chemical-science-pack'] = 15, + ['military-science-pack'] = 12, + ['production-science-pack'] = 25, + ['utility-science-pack'] = 50, + ['space-science-pack'] = 10, + ['enemy_killed'] = 10, -- Base XP for killing biters and spitters. + ['death-penalty'] = 0.0035, -- XP deduct in percentage of total experience when a player dies (Diggy default: 0.0035 which equals 0.35%) + --['cave-in-penalty'] = 100 -- XP lost every cave in. + ['infinity-research'] = 0.60 -- XP reward in percentage of the required experience from current level to next level (Diggy default: 0.60 which equals 60%) + }, + buffs = { + -- define new buffs here, they are handed out for each level + mining_speed = {value = 5, max = 10}, + inventory_slot = {value = 1, max = 100}, + -- double_level is the level interval for receiving a double bonus (Diggy default: 5 which equals every 5th level) + health_bonus = {value = 2.5, double_level = 5, max = 500} + }, + -- add or remove a table entry to add or remove a unlockable item from the market. + unlockables = { + {level = 2, price = 4, name = 'wood'}, + {level = 3, price = 5, name = 'stone-wall'}, + {level = 4, price = 20, name = 'pistol'}, + {level = 4, price = 5, name = 'firearm-magazine'}, + {level = 5, price = 100, name = 'light-armor'}, + {level = 6, price = 6, name = 'small-lamp'}, + {level = 6, price = 5, name = 'raw-fish'}, + {level = 8, price = 1, name = 'stone-brick'}, + {level = 10, price = 85, name = 'shotgun'}, + {level = 10, price = 4, name = 'shotgun-shell'}, + {level = 12, price = 200, name = 'heavy-armor'}, + {level = 14, price = 25, name = 'landfill'}, --Decreased to 25 from 35 + {level = 15, price = 85, name = 'submachine-gun'}, + {level = 18, price = 10, name = 'piercing-rounds-magazine'}, + {level = 18, price = 8, name = 'piercing-shotgun-shell'}, + {level = 19, price = 2, name = 'rail'}, + {level = 20, price = 50, name = 'locomotive'}, + {level = 20, price = 350, name = 'modular-armor'}, + {level = 21, price = 5, name = 'rail-signal'}, + {level = 22, price = 5, name = 'rail-chain-signal'}, + {level = 23, price = 15, name = 'train-stop'}, + {level = 24, price = 35, name = 'cargo-wagon'}, + {level = 24, price = 35, name = 'fluid-wagon'}, + {level = 26, price = 150, name = 'tank'}, + {level = 29, price = 750, name = 'power-armor'}, + {level = 30, price = 30, name = 'logistic-robot'}, + {level = 31, price = 200, name = 'personal-roboport-equipment'}, + {level = 32, price = 20, name = 'construction-robot'}, + {level = 34, price = 750, name = 'fusion-reactor-equipment'}, + {level = 35, price = 150, name = 'battery-equipment'}, + {level = 38, price = 250, name = 'exoskeleton-equipment'}, + {level = 40, price = 125, name = 'energy-shield-equipment'}, + {level = 42, price = 500, name = 'personal-laser-defense-equipment'}, + {level = 44, price = 1250, name = 'power-armor-mk2'}, + {level = 46, price = 750, name = 'battery-mk2-equipment'}, + {level = 48, price = 550, name = 'combat-shotgun'}, + {level = 51, price = 25, name = 'uranium-rounds-magazine'}, + {level = 63, price = 250, name = 'rocket-launcher'}, + {level = 63, price = 40, name = 'rocket'}, + {level = 71, price = 80, name = 'explosive-rocket'}, + {level = 78, price = 1000, name = 'satellite'}, + {level = 100, price = 2500, name = 'spidertron'}, + {level = 100, price = 1, name = 'iron-stick'} + }, + -- modifies the experience per alien type, higher is more xp + alien_experience_modifiers = { + ['small-biter'] = 2, + ['small-spitter'] = 2, + ['small-worm-turret'] = 2, + ['medium-biter'] = 3, + ['medium-spitter'] = 3, + ['medium-worm-turret'] = 3, + ['big-biter'] = 5, + ['big-spitter'] = 5, + ['big-worm-turret'] = 5, + ['behemoth-biter'] = 7, + ['behemoth-spitter'] = 7, + ['behemoth-worm-turret'] = 7 + } + }, + weapon_balance = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.weapon_balance') end + }, + danger_ore = { + enabled = true, + load = function() return require('map_gen.maps.diggy.feature.danger_ore') end, + allowed_entities = { + 'transport-belt', + 'fast-transport-belt', + 'express-transport-belt', + 'underground-belt', + 'fast-underground-belt', + 'express-underground-belt', + 'small-electric-pole', + 'medium-electric-pole', + 'big-electric-pole', + 'substation', + 'electric-mining-drill', + 'burner-mining-drill', + 'pumpjack', + 'car', + 'tank', + 'spidertron', + 'stone-wall', + 'small-lamp' + } + } + } +} + +ScenarioInfo.set_map_name('Diggy Danger Ores') +ScenarioInfo.set_map_description('Dig your way through!') + +local diggy = require 'map_gen.maps.diggy.scenario' +return diggy.register(config) diff --git a/map_gen/maps/diggy/config.lua b/map_gen/maps/diggy/presets/normal.lua similarity index 98% rename from map_gen/maps/diggy/config.lua rename to map_gen/maps/diggy/presets/normal.lua index 097b7799..4f3e75fc 100644 --- a/map_gen/maps/diggy/config.lua +++ b/map_gen/maps/diggy/presets/normal.lua @@ -1,8 +1,9 @@ -- dependencies +local ScenarioInfo = require 'features.gui.info' local abs = math.abs --- this -local Config = { +local config = { + scenario_name = 'diggy', -- a list of features to register and enable -- to disable a feature, change the flag features = { @@ -450,4 +451,8 @@ local Config = { } } -return Config +ScenarioInfo.set_map_name('Diggy') +ScenarioInfo.set_map_description('Dig your way through!') + +local diggy = require 'map_gen.maps.diggy.scenario' +return diggy.register(config) diff --git a/map_gen/maps/diggy/scenario.lua b/map_gen/maps/diggy/scenario.lua index 6c73f64f..2cf57fed 100644 --- a/map_gen/maps/diggy/scenario.lua +++ b/map_gen/maps/diggy/scenario.lua @@ -1,5 +1,4 @@ -- dependencies -local Config = require 'map_gen.maps.diggy.config' local ScenarioInfo = require 'features.gui.info' local RS = require 'map_gen.shared.redmew_surface' local Event = require 'utils.event' @@ -7,7 +6,6 @@ local pairs = pairs local type = type local restart_command = require 'map_gen.maps.diggy.feature.restart_command' -restart_command({scenario_name = 'diggy'}) require 'utils.table' require 'utils.core' @@ -26,13 +24,13 @@ global.diggy_scenario_registered = false @param if_enabled function to be called if enabled ]] -local function each_enabled_feature(if_enabled) +local function each_enabled_feature(diggy_config, if_enabled) local enabled_type = type(if_enabled) if ('function' ~= enabled_type) then error('each_enabled_feature expects callback to be a function, given type: ' .. enabled_type) end - for current_name, feature_data in pairs(Config.features) do + for current_name, feature_data in pairs(diggy_config.features) do if (nil == feature_data.enabled) then error('Feature ' .. current_name .. ' did not define the enabled property.') end @@ -44,7 +42,7 @@ local function each_enabled_feature(if_enabled) end ---Register the events required to initialize the scenario. -function Scenario.register() +function Scenario.register(diggy_config) if global.diggy_scenario_registered then error('Cannot register the Diggy scenario multiple times.') return @@ -57,7 +55,10 @@ function Scenario.register() redmew_config.hodor.enabled = false redmew_config.paint.enabled = false + restart_command({scenario_name = diggy_config.scenario_name}) + each_enabled_feature( + diggy_config, function(feature_name, feature_config) local feature = feature_config.load() if ('function' ~= type(feature.register)) then @@ -76,9 +77,6 @@ function Scenario.register() end ) - ScenarioInfo.set_map_name('Diggy') - ScenarioInfo.set_map_description('Dig your way through!') - global.diggy_scenario_registered = true end diff --git a/scenario_templates/diggy-danger-ores/map_selection.lua b/scenario_templates/diggy-danger-ores/map_selection.lua new file mode 100644 index 00000000..a7080d96 --- /dev/null +++ b/scenario_templates/diggy-danger-ores/map_selection.lua @@ -0,0 +1 @@ +return require 'map_gen.maps.diggy.presets.danger_ores' \ No newline at end of file