Skip to content

Commit

Permalink
other: The pressure dome atmosphere consumption now scales with quality.
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Dec 14, 2024
1 parent e2a91b6 commit 34fa1df
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 104 deletions.
40 changes: 38 additions & 2 deletions data-updates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require "prototypes.item-weight"
require "prototypes.default-import-location"
require "prototypes.fluid-void"
require "prototypes.item-sounds"
require "prototypes.regulator-fluidbox"
require "compat.aai-industry"
require "compat.transport-ring-teleporter"

Expand Down Expand Up @@ -91,7 +92,6 @@ require "prototypes.item-subgroups"
if mods["assembler-pipe-passthrough"] then
appmod.blacklist["maraxsis-hydro-plant"] = true
appmod.blacklist["maraxsis-hydro-plant-extra-module-slots"] = true
appmod.blacklist["maraxsis-regulator-fluidbox"] = true
end

data.raw.recipe["maraxsis-glass-panes-recycling"].results = {
Expand Down Expand Up @@ -136,4 +136,40 @@ data.raw.furnace["maraxsis-salt-reactor"].localised_description = {
data.raw["electric-energy-interface"]["maraxsis-salt-reactor-energy-interface"].localised_description = {
"entity-description.maraxsis-salt-reactor",
electricity_description
}
}

-- regulator factoriopedia description

local function add_quality_factoriopedia_info(entity, factoriopedia_info)
local factoriopedia_description

for _, factoriopedia_info in pairs(factoriopedia_info or {}) do
local header, factoriopedia_function = unpack(factoriopedia_info)
local localised_string = {"", "[font=default-semibold]", header, "[/font]"}

for _, quality in pairs(data.raw.quality) do
if quality.hidden then goto continue end

local quality_buff = factoriopedia_function(entity, quality)
if type(quality_buff) ~= "table" then quality_buff = tostring(quality_buff) end
table.insert(localised_string, {"", "\n[img=quality." .. quality.name .. "] ", {"quality-name." .. quality.name}, ": [font=default-semibold]", quality_buff, "[/font]"})
::continue::
end

if factoriopedia_description then
factoriopedia_description[#factoriopedia_description + 1] = "\n\n"
factoriopedia_description[#factoriopedia_description + 1] = maraxsis.shorten_localised_string(localised_string)
else
factoriopedia_description = localised_string
end
end

entity.factoriopedia_description = maraxsis.shorten_localised_string(factoriopedia_description)
end

add_quality_factoriopedia_info(data.raw["roboport"]["service_station"], {
{{"quality-tooltip.atmosphere-consumption"}, function(entity, quality_level)
local consumption_per_second = maraxsis.atmosphere_consumption(quality_level)
return tostring(consumption_per_second) .. "/s"
end}
})
6 changes: 5 additions & 1 deletion locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ maraxsis-sonar=Uses sound waves to detect objects underwater.
maraxsis-salt-reactor=Advanced nuclear reactor that generates power directly from salt. Higher quality salt generates more power.\n__1__
maraxsis-coral=An underwater biome with a high biodiversity of marine life.
maraxsis-fishing-tower=Automated fishery that attracts and catches fish.\nRequires [item=maraxsis-fish-food].\nRequires [tile=lowland-cream-red-underwater].
service_station=Consumes 5/s [fluid=maraxsis-atmosphere] to provide positive pressure to the dome. When powered, functions as an underwater [entity=roboport] and [entity=radar].\nProvides construction materials to [entity=constructron].
service_station=Consumes [fluid=maraxsis-atmosphere] to provide positive pressure to the dome. See Factoriopedia for the atmosphere consumption rate. When powered, functions as an underwater [entity=roboport] and [entity=radar].\nProvides construction materials to [entity=constructron].
maraxsis-trench-duct=An extremely long and durable pipe that transfers fluids directly to the trench and back.\nMust be placed on [tile=maraxsis-trench-entrance].\nRequires [item=cliff-explosives] to clear a path.\nThis duct must be placed on the edge of the trench entrance, similar to [entity=offshore-pump].
maraxsis-trench-duct-lower=An extremely long and durable pipe that transfers fluids directly to the trench and back.
maraxsis-conduit=Advanced beacon that can be placed on the seabed or on land. Has a huge coverage distance and can accept quality modules. Each placed conduit contributes only half as much distribution efficiency as the last.
maraxsis-polylplast=A conglomeration of millions of tiny animals.
[quality-tooltip]
atmosphere-consumption=Decreases the [fluid=maraxsis-atmosphere] consumption at higher qualities.
[item-name]
hydraulic-science-pack=Hydraulic science pack
maraxsis-sand=Sand
Expand Down Expand Up @@ -262,6 +265,7 @@ submerge=Submerge

[description]
base-quality=[font=default-semibold][color=255,230,192]Base quality:[/color][/font] __1__%
quality-diamond=[font=default-semibold][color=255,230,192]__1__ [img=quality_info][/color][/font]

[ctron_gui_locale]
main_title=Control Center
Expand Down
61 changes: 61 additions & 0 deletions migrations/quality-regulators.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
local function place_regulator(pressure_dome_data)
local surface = pressure_dome_data.surface
if not surface.valid then return end
local position = pressure_dome_data.position
local x, y = position.x, position.y
local force = pressure_dome_data.force_index
local quality = pressure_dome_data.quality

if not quality and pressure_dome_data.regulator and pressure_dome_data.regulator.valid then
quality = pressure_dome_data.regulator.quality
end

if not quality then
game.print("ERROR: quality is nil for pressure dome at [gps=" .. x .. "," .. y .. "," .. surface.name .. "]")
return
end

if type(quality) == "string" then
quality = prototypes.quality[quality]
end

local regulator = pressure_dome_data.regulator
if not regulator or not regulator.valid then
storage.script_placing_the_regulator = true
regulator = surface.create_entity {
name = "service_station",
position = {x, y},
quality = quality,
force = force,
create_build_effect_smoke = false,
raise_built = true,
}
storage.script_placing_the_regulator = false
end

regulator.minable = false
regulator.destructible = false
regulator.operable = true

pressure_dome_data.regulator = regulator

local regulator_fluidbox = pressure_dome_data.regulator_fluidbox
if not regulator_fluidbox or not regulator_fluidbox.valid then
regulator_fluidbox = surface.create_entity {
name = "maraxsis-regulator-fluidbox-" .. quality.name,
position = {x, y},
force = force,
create_build_effect_smoke = false,
}
end

regulator_fluidbox.minable = false
regulator_fluidbox.destructible = false
regulator_fluidbox.operable = false

pressure_dome_data.regulator_fluidbox = regulator_fluidbox
end

for _, dome_data in pairs(storage.pressure_domes or {}) do
place_regulator(dome_data)
end
123 changes: 123 additions & 0 deletions prototypes/regulator-fluidbox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
function maraxsis.atmosphere_consumption(quality)
if quality.hidden then error("hidden quality") end
local quality_level = quality.level + 1
if quality.name == "legendary" then quality_level = 5 end
local consumption_per_second
if quality_level <= 5 then
consumption_per_second = 6 - quality_level
else
consumption_per_second = 1 / (quality_level - 4)
end
return consumption_per_second, tostring(consumption_per_second * 100) .. "kW"
end

for _, quality in pairs(data.raw.quality) do
if quality.hidden then goto continue end

local _, energy_consumption = maraxsis.atmosphere_consumption(quality)

if mods["assembler-pipe-passthrough"] then
appmod.blacklist["maraxsis-regulator-fluidbox-" .. quality.name] = true
end

data:extend {{
type = "assembling-machine",
name = "maraxsis-regulator-fluidbox-" .. quality.name,
icon = "__maraxsis__/graphics/icons/regulator.png",
icon_size = 64,
flags = {"placeable-neutral", "player-creation", "not-on-map"},
minable = nil,
localised_name = {"entity-name.service_station"},
hidden = true,
quality_indicator_scale = 0,
max_health = 99999,
collision_mask = {layers = {}},
factoriopedia_alternative = "service_station",
collision_box = {{-1.9, -1.9}, {1.9, 1.9}},
selection_box = {{-2, -2}, {2, 2}},
selectable_in_game = false,
crafting_categories = {"maraxsis-regulator"},
crafting_speed = 1,
energy_usage = energy_consumption,
icon_draw_specification = {scale = 0, scale_for_many = 0},
fixed_recipe = "maraxsis-regulator",
working_sound = {
sound = {
filename = "__maraxsis__/sounds/regulator.ogg",
volume = 0.4
},
max_sounds_per_type = 3,
audible_distance_modifier = 0.5,
fade_in_ticks = 4,
fade_out_ticks = 20
},
energy_source = {
type = "fluid",
burns_fluid = false,
scale_fluid_usage = false,
destroy_non_fuel_fluid = false,
maximum_temperature = 0,
fluid_box = {
production_type = "input",
pipe_picture = require("__space-age__.prototypes.entity.electromagnetic-plant-pictures").pipe_pictures,
pipe_picture_frozen = require("__space-age__.prototypes.entity.electromagnetic-plant-pictures").pipe_pictures_frozen,
pipe_covers = pipecoverspictures(),
volume = 100,
pipe_connections = {
{position = {0.5, -1.5}, direction = defines.direction.north, flow_direction = "input-output"},
{position = {-0.5, 1.5}, direction = defines.direction.south, flow_direction = "input-output"},
{position = {1.5, 0.5}, direction = defines.direction.east, flow_direction = "input-output"},
{position = {-1.5, -0.5}, direction = defines.direction.west, flow_direction = "input-output"},
},
filter = "maraxsis-atmosphere",
secondary_draw_orders = {north = -1},
},
smoke = {
{
name = "maraxsis-swimming-bubbles",
frequency = 100,
position = {-0.9, -2.7},
starting_vertical_speed = 0.03
}
}
},
effect_receiver = {
uses_module_effects = false,
uses_beacon_effects = false,
uses_surface_effects = false,
},
graphics_set = {
animation = {
layers = {
{
filename = "__maraxsis__/graphics/entity/regulator/regulator.png",
priority = "high",
width = 1680 / 8,
height = 2320 / 8,
shift = {0, -0.5},
frame_count = 60,
line_length = 8,
animation_speed = 1.5,
scale = 0.5 * 4 / 3,
flags = {"no-scale"}
},
{
filename = "__maraxsis__/graphics/entity/regulator/sh.png",
priority = "high",
width = 400,
height = 350,
shift = util.by_pixel(0, -16),
frame_count = 1,
line_length = 1,
repeat_count = 60,
animation_speed = 1.5,
scale = 0.5 * 4 / 3,
draw_as_shadow = true,
}
}
}
}
}}

::continue::
end
99 changes: 0 additions & 99 deletions prototypes/regulator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,105 +54,6 @@ data.raw.recipe["service_station"].hidden = true
data.raw.item["service_station"].hidden = true
data.raw.item["service_station"].place_result = nil

data:extend {{
type = "assembling-machine",
name = "maraxsis-regulator-fluidbox",
icon = "__maraxsis__/graphics/icons/regulator.png",
icon_size = 64,
flags = {"placeable-neutral", "player-creation", "not-on-map"},
minable = nil,
localised_name = {"entity-name.service_station"},
hidden = true,
quality_indicator_scale = 0,
max_health = 99999,
collision_mask = {layers = {}},
factoriopedia_alternative = "service_station",
collision_box = {{-1.9, -1.9}, {1.9, 1.9}},
selection_box = {{-2, -2}, {2, 2}},
selectable_in_game = false,
crafting_categories = {"maraxsis-regulator"},
crafting_speed = 1,
energy_usage = "500kW",
icon_draw_specification = {scale = 0, scale_for_many = 0},
fixed_recipe = "maraxsis-regulator",
working_sound = {
sound = {
filename = "__maraxsis__/sounds/regulator.ogg",
volume = 0.4
},
max_sounds_per_type = 3,
audible_distance_modifier = 0.5,
fade_in_ticks = 4,
fade_out_ticks = 20
},
energy_source = {
type = "fluid",
burns_fluid = false,
scale_fluid_usage = false,
destroy_non_fuel_fluid = false,
maximum_temperature = 0,
fluid_box = {
production_type = "input",
pipe_picture = require("__space-age__.prototypes.entity.electromagnetic-plant-pictures").pipe_pictures,
pipe_picture_frozen = require("__space-age__.prototypes.entity.electromagnetic-plant-pictures").pipe_pictures_frozen,
pipe_covers = pipecoverspictures(),
volume = 100,
pipe_connections = {
{position = {0.5, -1.5}, direction = defines.direction.north, flow_direction = "input-output"},
{position = {-0.5, 1.5}, direction = defines.direction.south, flow_direction = "input-output"},
{position = {1.5, 0.5}, direction = defines.direction.east, flow_direction = "input-output"},
{position = {-1.5, -0.5}, direction = defines.direction.west, flow_direction = "input-output"},
},
filter = "maraxsis-atmosphere",
secondary_draw_orders = {north = -1},
},
smoke = {
{
name = "maraxsis-swimming-bubbles",
frequency = 100,
position = {-0.9, -2.7},
starting_vertical_speed = 0.03
}
}
},
effect_receiver = {
uses_module_effects = false,
uses_beacon_effects = false,
uses_surface_effects = false,
},
graphics_set = {
animation = {
layers = {
{
filename = "__maraxsis__/graphics/entity/regulator/regulator.png",
priority = "high",
width = 1680 / 8,
height = 2320 / 8,
shift = {0, -0.5},
frame_count = 60,
line_length = 8,
animation_speed = 1.5,
scale = 0.5 * 4 / 3,
flags = {"no-scale"}
},
{
filename = "__maraxsis__/graphics/entity/regulator/sh.png",
priority = "high",
width = 400,
height = 350,
shift = util.by_pixel(0, -16),
frame_count = 1,
line_length = 1,
repeat_count = 60,
animation_speed = 1.5,
scale = 0.5 * 4 / 3,
draw_as_shadow = true,
}
}
}
}
}}

data:extend {{
type = "recipe",
name = "maraxsis-regulator",
Expand Down
3 changes: 1 addition & 2 deletions scripts/pressure-dome.lua
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,9 @@ local function place_regulator(pressure_dome_data)
local regulator_fluidbox = pressure_dome_data.regulator_fluidbox
if not regulator_fluidbox or not regulator_fluidbox.valid then
regulator_fluidbox = surface.create_entity {
name = "maraxsis-regulator-fluidbox",
name = "maraxsis-regulator-fluidbox-" .. quality.name,
position = {x, y},
force = force,
--quality = quality, https://github.com/notnotmelon/maraxsis/issues/50
create_build_effect_smoke = false,
}
end
Expand Down

0 comments on commit 34fa1df

Please sign in to comment.