mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Backwards compatibility
Added conversion from old config to new
This commit is contained in:
parent
49babc20ff
commit
1fe198843d
@ -14,6 +14,7 @@ local compound = defines.command.compound
|
||||
local logical_or = defines.compound_command.logical_or
|
||||
local attack = defines.command.attack
|
||||
local attack_area = defines.command.attack_area
|
||||
local hail_hydra_conf = global.config.hail_hydra
|
||||
|
||||
local spawn_table = {}
|
||||
for k, v in pairs(global.config.hail_hydra.hydras) do
|
||||
@ -27,9 +28,10 @@ local function formula(evo)
|
||||
end
|
||||
|
||||
local primitives = {
|
||||
evolution_scale = formula,
|
||||
online_player_scale_enabled = global.config.hail_hydra.online_player_scale_enabled,
|
||||
online_player_scale = global.config.hail_hydra.online_player_scale,
|
||||
evolution_scale = (hail_hydra_conf.evolution_scale ~= nil) and hail_hydra_conf.evolution_scale or 1,
|
||||
evolution_scale_formula = formula,
|
||||
online_player_scale_enabled = hail_hydra_conf.online_player_scale_enabled,
|
||||
online_player_scale = hail_hydra_conf.online_player_scale,
|
||||
enabled = nil
|
||||
}
|
||||
|
||||
@ -46,6 +48,10 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function backwards_compatibility(amount)
|
||||
return {min = amount, max = amount + primitives.evolution_scale}
|
||||
end
|
||||
|
||||
local function create_attack_command(position, target)
|
||||
local command = {type = attack_area, destination = position, radius = 10}
|
||||
if target then
|
||||
@ -82,7 +88,7 @@ local on_died =
|
||||
player_scale = (num_online_players - primitives.online_player_scale) * 0.01
|
||||
end
|
||||
|
||||
local evolution_factor = primitives.evolution_scale(force.evolution_factor)
|
||||
local evolution_factor = primitives.evolution_scale_formula(force.evolution_factor)
|
||||
evolution_factor = evolution_factor + evolution_factor * player_scale
|
||||
|
||||
local cause = event.cause
|
||||
@ -93,13 +99,16 @@ local on_died =
|
||||
local command = create_attack_command(position, cause)
|
||||
|
||||
for hydra_spawn, amount in pairs(hydra) do
|
||||
if (type(amount) == 'number') then
|
||||
amount = backwards_compatibility(amount)
|
||||
end
|
||||
local trigger = amount.trigger
|
||||
if trigger == nil or trigger < force.evolution_factor then
|
||||
local max = amount.max
|
||||
local min = amount.min
|
||||
local max = amount.max
|
||||
max = (max ~= nil and max >= min) and max or min
|
||||
if max ~= min then
|
||||
amount = (max - min) * (evolution_factor / primitives.evolution_scale(1)) + min
|
||||
amount = (max - min) * (evolution_factor / primitives.evolution_scale_formula(1)) + min
|
||||
else
|
||||
amount = min
|
||||
end
|
||||
@ -165,6 +174,18 @@ function Public.set_evolution_scale(scale)
|
||||
primitives.evolution_scale = scale
|
||||
end
|
||||
|
||||
--- Sets the online player scale
|
||||
-- @param scale <number>
|
||||
function Public.set_evolution_scale(scale)
|
||||
primitives.online_player_scale = scale
|
||||
end
|
||||
|
||||
--- Toggles the online player scale feature
|
||||
-- @param enable <boolean>
|
||||
function Public.set_evolution_scale(enabled)
|
||||
primitives.online_player_scale_enabled = enabled
|
||||
end
|
||||
|
||||
--- Sets the hydra spawning table
|
||||
-- @param hydras <table> see config.lua's hail_hydra section for example
|
||||
function Public.set_hydras(hydras)
|
||||
|
Loading…
x
Reference in New Issue
Block a user