Merge branch 'experimental' into main

This commit is contained in:
Monica Moniot
2022-12-12 08:01:41 -05:00
committed by GitHub
9 changed files with 81 additions and 69 deletions

2
.vscode/launch.json vendored
View File

@@ -42,7 +42,7 @@
"flib": true, "flib": true,
"cybersyn": true, "cybersyn": true,
}, },
"disableExtraMods": true //"disableExtraMods": true
}, },
{ {
"type": "factoriomod", "type": "factoriomod",

View File

@@ -1,14 +1,16 @@
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 1.1.2 Version: 1.1.4
Date: 2022-12-8 Date: 2022-12-9
Changes: Changes:
- Fixed a crash on newly generated worlds - Made the recipe and research requirements for cybernetic combinators cheaper so that access to them in various modpacks is more in line with my intentions
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 1.1.1 Version: 1.1.3
Date: 2022-12-8 Date: 2022-12-8
Changes: Changes:
- Fixed a crash when removing a fuel loader - Fixed a crash when removing a fuel loader
- Fixed a gui bug - Fixed a gui bug
- Fixed a crash on newly generated worlds
- Fixed a crash with breaking combinators
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 1.1.0 Version: 1.1.0
Date: 2022-12-8 Date: 2022-12-8

View File

@@ -1,6 +1,6 @@
{ {
"name": "cybersyn", "name": "cybersyn",
"version": "1.1.2", "version": "1.1.4",
"title": "Project Cybersyn", "title": "Project Cybersyn",
"author": "Mami", "author": "Mami",
"factorio_version": "1.1", "factorio_version": "1.1",

View File

@@ -32,7 +32,7 @@ cybersyn-combinator-output=Cybernetic combinator output
cybersyn-combinator=Has 4 different control modes. Primary control allows providing and requesting. Optional Control allows setting thresholds per-item and reading all in progress deliveries. Depot control allows parked trains to be added to the network. Wagon control allows for reading the desired contents of the adjacent wagon. cybersyn-combinator=Has 4 different control modes. Primary control allows providing and requesting. Optional Control allows setting thresholds per-item and reading all in progress deliveries. Depot control allows parked trains to be added to the network. Wagon control allows for reading the desired contents of the adjacent wagon.
[technology-name] [technology-name]
cybersyn-train-network=Cybernetic train network cybersyn-train-network=Cybersyn train network
[technology-description] [technology-description]
cybersyn-train-network=Train stop controllers capable of coordinating the inputs and outputs of an entire economy. cybersyn-train-network=Train stop controllers capable of coordinating the inputs and outputs of an entire economy.

View File

@@ -1,8 +1,8 @@
--By Mami --By Mami
combinator_recipe = flib.copy_prototype(data.raw["recipe"]["train-stop"], COMBINATOR_NAME) combinator_recipe = flib.copy_prototype(data.raw["recipe"]["arithmetic-combinator"], COMBINATOR_NAME)
combinator_recipe.ingredients = { combinator_recipe.ingredients = {
{"copper-cable", 5}, {"copper-cable", 20},
{"advanced-circuit", 5}, {"electronic-circuit", 10},
} }
combinator_recipe.enabled = false combinator_recipe.enabled = false
if (mods["nullius"]) then if (mods["nullius"]) then
@@ -19,38 +19,27 @@ if (mods["nullius"]) then
} }
end end
cybersyn_tech = {
type = "technology", cybersyn_tech = flib.copy_prototype(data.raw["technology"]["automated-rail-transportation"], "cybersyn-train-network")
name = "cybersyn-train-network",
icon = "__cybersyn__/graphics/icons/tech.png", cybersyn_tech.icon = "__cybersyn__/graphics/icons/tech.png"
icon_size = 256, cybersyn_tech.icon_size = 256
--icon_mipmaps = 4, cybersyn_tech.prerequisites = {
prerequisites = { "automated-rail-transportation",
"automated-rail-transportation", "circuit-network",
"circuit-network",
"advanced-electronics"
},
effects = {
{
type = "unlock-recipe",
recipe = COMBINATOR_NAME
},
},
unit = {
ingredients = {
{"automation-science-pack", 1},
{"logistic-science-pack", 1}
},
count = 250,
time = 30
},
order = "c-g-c"
} }
cybersyn_tech.effects = {
{
type = "unlock-recipe",
recipe = COMBINATOR_NAME
},
}
cybersyn_tech.unit.count = 3*cybersyn_tech.unit.count
cybersyn_tech.order = "c-g-c"
if (mods["nullius"]) then if (mods["nullius"]) then
-- Enable technology -- Enable technology
cybersyn_tech.order = "nullius-" .. (cybersyn_tech.order or "") cybersyn_tech.order = "nullius-" .. (cybersyn_tech.order or "")
-- Use the same costs and requirements as for LTN
cybersyn_tech.unit = { cybersyn_tech.unit = {
count = 100, count = 100,
ingredients = { ingredients = {
@@ -61,4 +50,4 @@ if (mods["nullius"]) then
} }
cybersyn_tech.prerequisites = { "nullius-checkpoint-optimization", "nullius-traffic-control" } cybersyn_tech.prerequisites = { "nullius-checkpoint-optimization", "nullius-traffic-control" }
cybersyn_tech.ignore_tech_tech_cost_multiplier = true cybersyn_tech.ignore_tech_tech_cost_multiplier = true
end end

View File

@@ -29,6 +29,8 @@ STATUS_NAMES_DEFAULT = "entity-status.disabled"
---@param comb LuaEntity ---@param comb LuaEntity
---@param player LuaPlayer ---@param player LuaPlayer
function gui_opened(comb, player) function gui_opened(comb, player)
combinator_update(global, comb)
local rootgui = player.gui.screen local rootgui = player.gui.screen
local selected_index, signal, check, switch_state = get_comb_gui_settings(comb) local selected_index, signal, check, switch_state = get_comb_gui_settings(comb)

View File

@@ -90,7 +90,7 @@ local function on_refueler_broken(map_data, refueler_id, refueler)
map_data.to_refuelers[refueler.network_name] = nil map_data.to_refuelers[refueler.network_name] = nil
end end
end end
map_data.stations[refueler_id] = nil map_data.refuelers[refueler_id] = nil
interface_raise_refueler_removed(refueler_id, refueler) interface_raise_refueler_removed(refueler_id, refueler)
end end
@@ -333,7 +333,7 @@ function on_combinator_network_updated(map_data, comb, network_name)
refueler.network_name = network_name refueler.network_name = network_name
if network_name then if network_name then
local network = map_data.to_refuelers[network_name] local network = map_data.to_refuelers[network_name]
if network == nil then if not network then
network = {} network = {}
map_data.to_refuelers[network_name] = network map_data.to_refuelers[network_name] = network
end end
@@ -398,18 +398,33 @@ function combinator_update(map_data, comb)
local old_params = map_data.to_comb_params[unit_number] local old_params = map_data.to_comb_params[unit_number]
local has_changed = false local has_changed = false
if params.operation ~= old_params.operation then local stop = map_data.to_stop[comb.unit_number]
if (old_params.operation == MODE_PRIMARY_IO) and (params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST) then if stop then
id = stop.unit_number
station = map_data.stations[id]
if station then
--make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params --make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params
params.operation = MODE_PRIMARY_IO if station.display_state >= 2 then
else params.operation = MODE_PRIMARY_IO_ACTIVE
--NOTE: This is rather dangerous, we may need to actually implement operation changing elseif station.display_state == 1 then
on_combinator_broken(map_data, comb) params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
on_combinator_built(map_data, comb) else
interface_raise_combinator_changed(comb, old_params) params.operation = MODE_PRIMARY_IO
return end
control.parameters = params
end end
end end
if params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST then
params.operation = MODE_PRIMARY_IO
end
if params.operation ~= old_params.operation then
--NOTE: This is rather dangerous, we may need to actually implement operation changing
on_combinator_broken(map_data, comb)
on_combinator_built(map_data, comb)
interface_raise_combinator_changed(comb, old_params)
return
end
local new_signal = params.first_signal local new_signal = params.first_signal
local old_signal = old_params.first_signal local old_signal = old_params.first_signal
local new_network = new_signal and new_signal.name or nil local new_network = new_signal and new_signal.name or nil
@@ -420,24 +435,19 @@ function combinator_update(map_data, comb)
end end
if params.second_constant ~= old_params.second_constant then if params.second_constant ~= old_params.second_constant then
has_changed = true has_changed = true
local stop = map_data.to_stop[comb.unit_number] if station then
if stop then local pre = station.allows_all_trains
local id = stop.unit_number set_station_from_comb_state(station)
local station = map_data.stations[id] if station.allows_all_trains ~= pre then
if station then update_stop_if_auto(map_data, station, true)
local pre = station.allows_all_trains end
set_station_from_comb_state(station) else
if station.allows_all_trains ~= pre then local refueler = map_data.refuelers[id]
update_stop_if_auto(map_data, station, true) if refueler then
end local pre = refueler.allows_all_trains
else set_refueler_from_comb(mod_settings, refueler)
local refueler = map_data.refuelers[id] if refueler.allows_all_trains ~= pre then
if refueler then update_stop_if_auto(map_data, refueler, false)
local pre = refueler.allows_all_trains
set_refueler_from_comb(mod_settings, refueler)
if refueler.allows_all_trains ~= pre then
update_stop_if_auto(map_data, refueler, false)
end
end end
end end
end end

View File

@@ -103,6 +103,17 @@ local migrations_table = {
map_data.refuelers = map_data.refuelers or {} map_data.refuelers = map_data.refuelers or {}
map_data.to_refuelers = map_data.to_refuelers or {} map_data.to_refuelers = map_data.to_refuelers or {}
end, end,
["1.1.3"] = function()
---@type MapData
local map_data = global
map_data.tick_state = STATE_INIT
map_data.tick_data = {}
for k, v in pairs(map_data.refuelers) do
if not v.entity_comb.valid or not v.entity_stop.valid then
map_data.refuelers[k] = nil
end
end
end,
} }
--STATUS_R_TO_D = 5 --STATUS_R_TO_D = 5

View File

@@ -374,9 +374,7 @@ local function on_train_leaves_stop(map_data, mod_settings, train_id, train)
interface_raise_train_status_changed(train_id, STATUS_F, train.status) interface_raise_train_status_changed(train_id, STATUS_F, train.status)
elseif train.status == STATUS_D then elseif train.status == STATUS_D then
--The train is leaving the depot without a manifest, the player likely intervened --The train is leaving the depot without a manifest, the player likely intervened
local depot = map_data.depots[train.parked_at_depot_id--[[@as uint]]]
remove_train(map_data, train_id, train) remove_train(map_data, train_id, train)
send_lost_train_alert(train.entity, depot.entity_stop.backer_name)
end end
end end