Merge pull request #486 from bbassie/feature/convert-configs

Convert the remaining scenario configs into features
This commit is contained in:
Bastiaan authored and GitHub committed 2026-10-05 00:33:36 +01:00
1 parent b4ee485b13
commit 757a36fc03
44 files changed
+2137 -2033

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
--- This file contains all the different settings for the autofill system and gui
-- @config Autofill
local config = {
-- General config
icon = "item/piercing-rounds-magazine", -- that will be used for the toolbar
categories = {
ammo = "ammo",
fuel = "fuel",
shell = "shell",
},
entities = {
car = "car",
tank = "tank",
spidertron = "spidertron",
locomotive = "locomotive",
gun_turret = "gun-turret",
burner_mining_drill = "burner-mining-drill",
stone_furnace = "stone-furnace",
steel_furnace = "steel-furnace",
},
default_entities = {},
}
local default_categories = {
{
category = config.categories.ammo,
entity = { config.entities.car, config.entities.tank, config.entities.gun_turret },
inv = { defines.inventory.car_ammo, defines.inventory.turret_ammo },
items = {
{ name = "uranium-rounds-magazine", amount = 10, enabled = false },
{ name = "piercing-rounds-magazine", amount = 10, enabled = false },
{ name = "firearm-magazine", amount = 10, enabled = false },
},
},
{
category = config.categories.ammo,
entity = { config.entities.tank },
inv = { defines.inventory.car_ammo },
items = {
{ name = "flamethrower-ammo", amount = 10, enabled = false },
},
},
{
category = config.categories.shell,
entity = { config.entities.tank },
inv = { defines.inventory.car_ammo },
items = {
{ name = "cannon-shell", amount = 10, enabled = false },
{ name = "explosive-cannon-shell", amount = 10, enabled = false },
{ name = "uranium-cannon-shell", amount = 10, enabled = false },
{ name = "explosive-uranium-cannon-shell", amount = 10, enabled = false },
},
},
{
category = config.categories.ammo,
entity = { config.entities.spidertron },
inv = { defines.inventory.car_ammo },
items = {
{ name = "rocket", amount = 10, enabled = false },
{ name = "explosive-rocket", amount = 10, enabled = false },
{ name = "atomic-bomb", amount = 10, enabled = false },
},
},
{
category = config.categories.fuel,
entity = { config.entities.car, config.entities.tank, config.entities.locomotive, config.entities.burner_mining_drill, config.entities.stone_furnace, config.entities.steel_furnace },
inv = { defines.inventory.fuel },
items = {
{ name = "nuclear-fuel", amount = 10, enabled = false },
{ name = "rocket-fuel", amount = 10, enabled = false },
{ name = "solid-fuel", amount = 10, enabled = false },
{ name = "coal", amount = 10, enabled = false },
},
},
}
local function get_items_by_inv(entity, inv)
local items = entity.items
for _, category in pairs(default_categories) do
if table.contains(category.entity, entity.entity) then
if table.contains(category.inv, inv) then
for _, item in pairs(category.items) do
items[item.name] = {
entity = entity.entity,
category = category.category,
inv = inv,
name = item.name,
amount = item.amount,
enabled = item.enabled,
}
end
end
end
end
return items
end
local function generate_default_setting(entity_name, inv, enabled)
if not config.default_entities[entity_name] then
config.default_entities[entity_name] = {
entity = entity_name,
enabled = enabled,
items = {},
}
end
get_items_by_inv(config.default_entities[entity_name], inv)
end
generate_default_setting(config.entities.car, defines.inventory.fuel, true)
generate_default_setting(config.entities.car, defines.inventory.car_ammo, true)
generate_default_setting(config.entities.locomotive, defines.inventory.fuel, true)
generate_default_setting(config.entities.tank, defines.inventory.fuel, true)
generate_default_setting(config.entities.tank, defines.inventory.car_ammo, true)
generate_default_setting(config.entities.spidertron, defines.inventory.car_ammo, true)
generate_default_setting(config.entities.gun_turret, defines.inventory.turret_ammo, true)
generate_default_setting(config.entities.burner_mining_drill, defines.inventory.fuel, true)
generate_default_setting(config.entities.stone_furnace, defines.inventory.fuel, true)
generate_default_setting(config.entities.steel_furnace, defines.inventory.fuel, true)
return config
@@ -0,0 +1,82 @@
--- The machines the module inserter can fill, and the modules it puts in them, by mod set
-- @config Module-Inserter-Machines
return {
["base"] = {
["electric-mining-drill"] = {
["module"] = "efficiency-module",
["prod"] = true,
},
["pumpjack"] = {
["module"] = "efficiency-module",
["prod"] = true,
},
["assembling-machine-2"] = {
["module"] = "productivity-module",
["prod"] = true,
},
["assembling-machine-3"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["electric-furnace"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["beacon"] = {
["module"] = "speed-module-3",
["prod"] = false,
},
["oil-refinery"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["chemical-plant"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["centrifuge"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["lab"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["rocket-silo"] = {
["module"] = "productivity-module-3",
["prod"] = true,
}
},
["space-age"] = {
["big-mining-drill"] = {
["module"] = "efficiency-module",
["prod"] = true,
},
["biochamber"] = {
["module"] = "efficiency-module",
["prod"] = true,
},
["electromagnetic-plant"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["cryogenic-plant"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["biolab"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["foundry"] = {
["module"] = "productivity-module-3",
["prod"] = true,
},
["recycler"] = {
["module"] = "quality-module-3",
["prod"] = true,
}
}
}
@@ -0,0 +1,63 @@
--- The bonuses players can spend their points on, see gui/player_bonus.lua
-- @config Player-Bonus
return {
{
name = "character_mining_speed_modifier",
scale = 1,
cost = 10,
max_value = 4,
value_step = 0.5,
is_percentage = true,
},
{
name = "character_running_speed_modifier",
scale = 1,
cost = 60,
max_value = 2,
value_step = 0.25,
is_percentage = true,
},
{
name = "character_crafting_speed_modifier",
scale = 1,
cost = 4,
max_value = 12,
value_step = 1,
is_percentage = true,
},
{
name = "character_inventory_slots_bonus",
scale = 10,
cost = 2,
max_value = 100,
value_step = 10,
},
{
name = "character_health_bonus",
scale = 50,
cost = 4,
max_value = 300,
value_step = 50,
},
{
name = "character_reach_distance_bonus",
scale = 1,
cost = 1,
max_value = 16,
value_step = 2,
combined_bonus = {
"character_resource_reach_distance_bonus",
"character_build_distance_bonus",
},
},
{
name = "personal_battery_recharge",
scale = 4,
cost = 40,
max_value = 8,
value_step = 1,
is_special = true,
},
}
@@ -0,0 +1,169 @@
--- Research data by mod set, the first set in mod_set_lookup whose mod is active is used
-- @config Research-Data
local data = {
mod_set_lookup = {
"space-age",
},
final_res = {
["base"] = {
["name"] = "mining-productivity-4",
["level"] = 4
},
["space-age"] = {
["name"] = "mining-productivity-3",
["level"] = 3
}
},
milestone = {
["base"] = {
["automation"] = 600,
["logistics"] = 300,
["steel-processing"] = 300,
["logistic-science-pack"] = 300,
["electronics"] = 300,
["fast-inserter"] = 300,
["steel-axe"] = 300,
["automation-2"] = 300,
["advanced-material-processing"] = 300,
["engine"] = 300,
["fluid-handling"] = 300,
["oil-processing"] = 300,
["sulfur-processing"] = 300,
["plastics"] = 300,
["advanced-circuit"] = 300,
["chemical-science-pack"] = 300,
["modules"] = 300,
["logistics-2"] = 300,
["railway"] = 300,
["research-speed-1"] = 300,
["research-speed-2"] = 300,
["battery"] = 300,
["concrete"] = 300,
["flammables"] = 300,
["low-density-structure"] = 300,
["advanced-material-processing-2"] = 300,
["productivity-module"] = 300,
["production-science-pack"] = 300,
["processing-unit"] = 300,
["advanced-oil-processing"] = 300,
["electric-engine"] = 300,
["robotics"] = 300,
["construction-robotics"] = 300,
["worker-robots-speed-1"] = 300,
["worker-robots-speed-2"] = 300,
["utility-science-pack"] = 300,
["productivity-module-2"] = 300,
["speed-module-2"] = 300,
["rocket-fuel"] = 300,
["effect-transmission"] = 300,
["productivity-module-3"] = 300,
["speed-module-3"] = 300,
["rocket-silo"] = 300,
["space-science-pack"] = 300,
},
["space-age"] = {
["logistic-science-pack"] = 3600,
["military-science-pack"] = 3600,
["chemical-science-pack"] = 5400,
["utility-science-pack"] = 7200,
["production-science-pack"] = 7200,
["space-science-pack"] = 7200,
["metallurgic-science-pack"] = 10800,
["electromagnetic-science-pack"] = 10800,
["agricultural-science-pack"] = 10800,
["cryogenic-science-pack"] = 10800,
["promethium-science-pack"] = 14400,
}
},
inf_res = {
["base"] = {
-- Mining Productivity
["mining-productivity-4"] = 4,
-- Robot Speed
["worker-robots-speed-6"] = 6,
-- Laser Damage
["energy-weapons-damage-7"] = 7,
-- Explosive Damage
["stronger-explosives-7"] = 7,
-- Bullet Damage
["physical-projectile-damage-7"] = 7,
-- Flame Damage
["refined-flammables-7"] = 7,
-- Artillery Range
["artillery-shell-range-1"] = 1,
-- Artillery Speed
["artillery-shell-speed-1"] = 1,
-- Follower Robot Count
["follower-robot-count-5"] = 5,
},
["space-age"] = {
-- Mining Productivity
["mining-productivity-3"] = 3,
-- Robot Speed
["worker-robots-speed-7"] = 7,
-- Laser Damage
["laser-weapons-damage-7"] = 7,
-- Electric Damage
["electric-weapons-damage-4"] = 4,
-- Explosive Damage
["stronger-explosives-7"] = 7,
-- Bullet Damage
["physical-projectile-damage-7"] = 7,
-- Flame Damage
["refined-flammables-7"] = 7,
-- Artillery Range
["artillery-shell-range-1"] = 1,
-- Artillery Speed
["artillery-shell-speed-1"] = 1,
-- Artillery Damage
["artillery-shell-damage-1"] = 1,
-- Railgun Speed
["railgun-shooting-speed-1"] = 1,
-- Railgun Damage
["railgun-damage-1"] = 1,
-- Health
["health"] = 1,
-- Research Productivity
["research-productivity"] = 1,
-- Scrap Recycling Productivity
["scrap-recycling-productivity"] = 1,
-- Asteroid Productivity
["asteroid-productivity"] = 1,
-- Processing Unit Productivity
["processing-unit-productivity"] = 1,
-- Steel Plate Productivity
["steel-plate-productivity"] = 1,
-- Low Density Structure Productivity
["low-density-structure-productivity"] = 1,
-- Plastic Bar Productivity
["plastic-bar-productivity"] = 1,
-- Rocket Fuel Productivity
["rocket-fuel-productivity"] = 1,
-- Rocket Part Productivity
["rocket-part-productivity"] = 1,
-- Follower Robot Count
["follower-robot-count-5"] = 5,
},
},
-- prevent research up to a certain level
limit_res = {
-- Artillery Range
["artillery-shell-range-1"] = 7,
-- Artillery Speed
["artillery-shell-speed-1"] = 7,
-- Atomic Bomb
-- ["atomic-bomb"] = 1
},
}
data.mod_set = "base"
for _, mod_name in ipairs(data.mod_set_lookup) do
if script.active_mods[mod_name] then
data.mod_set = mod_name
break
end
end
return data
@@ -0,0 +1,103 @@
--- The items players start with, and how many depending on what the factory has made
-- @config Starting-Items
--- These are called factories because they return another function
-- use these as a simple methods of adding new items
-- they will do most of the work for you
-- ['item-name'] = factory(params)
-- Use these to adjust for ticks ie game.tick < 5*minutes
local seconds, minutes, hours = 60, 3600, 216000
--- Use to make a split point for the number of items given based on time
-- ['stone-furnace']=cutoff_time(5*minutes, 4,0) -- before 5 minutes give four items after 5 minutes give none
local function cutoff_time(time, before, after)
return function(amount_made, items_made, player)
if game.tick < time then
return before
else
return after
end
end
end
--- Use to make a split point for the number of items given based on amount made
-- ['firearm-magazine']=cutoff_amount_made(100, 10, 0) -- give 10 items until 100 items have been made
local function cutoff_amount_made(amount, before, after)
return function(amount_made, items_made, player)
if amount_made < amount then
return before
else
return after
end
end
end
--- Same as above but will not give any items if x amount has been made of another item, useful for tiers
-- ['light-armor']=cutoff_amount_made_unless(5, 0,1,'heavy-armor',5) -- give light armor once 5 have been made unless 5 heavy armor has been made
local function cutoff_amount_made_unless(amount, before, after, second_item, second_amount)
return function(amount_made, items_made, player)
if items_made(second_item) < second_amount then
if amount_made < amount then
return before
else
return after
end
else
return 0
end
end
end
-- Use for mass production items where you want the amount to change based on the amount already made
-- ['iron-plate']=scale_amount_made(5*minutes, 10, 10) -- for first 5 minutes give 10 items then after apply a factor of 10
local function scale_amount_made(amount, before, scalar)
return function(amount_made, items_made, player)
if amount_made < amount then
return before
else
return (amount_made * scalar) / ((game.tick / minutes) ^ 2)
end
end
end
--[[
Common values
game.tick is the amount of time the game has been on for
amount_made is the amount of that item which has been made
items_made('item-name') will return the amount of any item made
player is the player who just spawned
hours, minutes, seconds are the number of ticks in each unit of time
]]
--- @type table<string, number | fun(amount_made: number, items_made: fun(name: string): number, player: LuaPlayer): number>
return {
-- ['item-name'] = function(amount_made, production_stats, player) return <Number> end -- 0 means no items given
-- Plates
["iron-plate"] = scale_amount_made(100, 10, 10),
["copper-plate"] = scale_amount_made(100, 0, 8),
["steel-plate"] = scale_amount_made(100, 0, 4),
-- Secondary Items
["electronic-circuit"] = scale_amount_made(1000, 0, 6),
["iron-gear-wheel"] = scale_amount_made(1000, 0, 6),
-- Starting Items
["burner-mining-drill"] = cutoff_time(10 * minutes, 4, 0),
["stone-furnace"] = cutoff_time(10 * minutes, 4, 0),
-- Armor
["light-armor"] = cutoff_amount_made_unless(5, 0, 1, "heavy-armor", 5),
["heavy-armor"] = cutoff_amount_made(5, 0, 1),
-- Weapon
["pistol"] = cutoff_amount_made_unless(0, 1, 1, "submachine-gun", 5),
["submachine-gun"] = cutoff_amount_made(5, 0, 1),
-- Ammo
["firearm-magazine"] = cutoff_amount_made_unless(100, 10, 0, "piercing-rounds-magazine", 100),
["piercing-rounds-magazine"] = cutoff_amount_made(100, 0, 10),
--[[
['construction-robot'] = 10,
['modular-armor'] = 1,
['solar-panel-equipment'] = 16,
['belt-immunity-equipment'] = 1,
['battery-equipment'] = 2,
['personal-roboport-equipment'] = 1
]]
}
+147
View File
@@ -0,0 +1,147 @@
--- The items the vlayer can hold and what they do, see control/vlayer.lua
-- @config Vlayer-Items
return {
--- @class Vlayer.ItemProperties
--- @field starting_value number
--- @field required_area number
--- @field production number?
--- @field discharge number?
--- @field capacity number?
--- @field surface_area number?
--- @field fuel_value number?
--- @field power boolean?
--- @field modded boolean? Set when the item is registered from a modded equivalent
--- @field base_game_equivalent string?
--- @field multiplier number?
--- @type table<string, Vlayer.ItemProperties>
allowed_items = { -- List of all items allowed in vlayer storage and their properties
--[[
Allowed properties:
starting_value : The amount of the item placed into the vlayer on game start, ignores area requirements
required_area : When greater than 0 the items properties are not applied unless their is sufficient surplus surface area
production : The energy production of the item in MW, used for solar panels
discharge : The energy discharge of the item in MW, used for accumulators
capacity : The energy capacity of the item in MJ, used for accumulators
surface_area : The surface area provided by the item, used for landfill
]]
["solar-panel"] = {
starting_value = 0,
required_area = 9,
production = 0.06, -- MW
},
["accumulator"] = {
starting_value = 0,
required_area = 4,
discharge = 0.3, -- MW
capacity = 5, -- MJ
},
["landfill"] = {
starting_value = 0,
required_area = 0,
surface_area = 20, -- Tiles
},
["wood"] = {
starting_value = 0,
required_area = 0,
surface_area = 0,
fuel_value = 2, -- MJ
power = true, -- turn all wood to power to reduce trash
},
["coal"] = {
starting_value = 0,
required_area = 0,
surface_area = 0,
fuel_value = 4, -- MJ
power = false, -- turn all coal to power to reduce trash
},
["solid-fuel"] = {
starting_value = 0,
required_area = 0,
surface_area = 0,
fuel_value = 12, -- MJ
power = false, -- turn all solid fuel to power to reduce trash
},
["rocket-fuel"] = {
starting_value = 0,
required_area = 0,
surface_area = 0,
fuel_value = 100, -- MJ
power = false, -- turn all rocket fuel to power to reduce trash
}
},
modded_items = { -- List of all modded items allowed in vlayer storage and their base game equivalent
["solar-panel-2"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 4,
},
["solar-panel-3"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 16,
},
["solar-panel-4"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 64,
},
["solar-panel-5"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 256,
},
["solar-panel-6"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 1024,
},
["solar-panel-7"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 4096,
},
["solar-panel-8"] = {
starting_value = 0,
base_game_equivalent = "solar-panel",
multiplier = 16384,
},
["accumulator-2"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 4,
},
["accumulator-3"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 16,
},
["accumulator-4"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 64,
},
["accumulator-5"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 256,
},
["accumulator-6"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 1024,
},
["accumulator-7"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 4096,
},
["accumulator-8"] = {
starting_value = 0,
base_game_equivalent = "accumulator",
multiplier = 16384,
},
}
}