Experimental (#23)

1.2.6
This commit is contained in:
Monica Moniot
2022-12-31 12:16:19 -05:00
committed by GitHub
parent 393b35b228
commit e2a05db7ec
7 changed files with 91 additions and 38 deletions

View File

@@ -24,6 +24,7 @@
"./.vscode/factorio"
],
"Lua.workspace.userThirdParty": [
"/home/mami/.config/Code/User/workspaceStorage/9536dbf0665a54126a4b0958ecd5829f/justarandomgeek.factoriomod-debug/sumneko-3rd"
"/home/mami/.config/Code/User/workspaceStorage/9536dbf0665a54126a4b0958ecd5829f/justarandomgeek.factoriomod-debug/sumneko-3rd",
"/home/mami/.config/Code/User/workspaceStorage/fdae937c5189f993d370b36f3104188f/justarandomgeek.factoriomod-debug/sumneko-3rd"
]
}

21
TODO
View File

@@ -1,19 +1,32 @@
bugs:
https://mods.factorio.com/mod/cybersyn/discussion/63a52e54be4341bccc0446f8
https://mods.factorio.com/mod/cybersyn/discussion/63afff871c9e44028b2acab8
https://mods.factorio.com/mod/cybersyn/discussion/63af6ed2f532e8870d639157
major:
debug output
add in game guide
gui-based system readout:
absolute count of unfulfilled requests
item count of unfulfilled requests
absolute count of available provides (is this even possible without a provide threshold?)
item count of available provides
system log
check out LTN addons that do this for inspiration
move to an event based algorithm
models & art
minor:
check if necessary entities can be destroyed without raising events
improve the behavior of trains if players intervene during deliveries
handle if signals are removed from the game during migration
update wagon control combinators immediately upon placement
railloader compat
deadlocks signals compat
close gui when the combinator is destroyed
do not play close sound when a different gui is opened
gui can desync if settings are changed outside of it while it is open
give the combinators a sensible reaction to low or no power
picker dollies compat?
compat:
train upgrader mod
deadlocks signals
railloader
picker dollies?

View File

@@ -1,4 +1,10 @@
---------------------------------------------------------------------------------------------------
Version: 1.2.6
Date: 2022-12-30
Bugfixes:
- Fixed a crash when deconstructing the connected rail of a station
- Improved the stability of migrations
---------------------------------------------------------------------------------------------------
Version: 1.2.5
Date: 2022-12-30
Bugfixes:

View File

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

View File

@@ -169,6 +169,29 @@ end
---@param start_at_depot boolean?
function set_manifest_schedule(map_data, train, depot_stop, same_depot, p_stop, p_enable_inactive, r_stop, r_enable_inactive, manifest, start_at_depot)
--NOTE: can only return false if start_at_depot is false, it should be incredibly rare that this function returns false
if not p_stop.connected_rail or not r_stop.connected_rail then
--NOTE: create a schedule that cannot be fulfilled, the train will be stuck but it will give the player information what went wrong
train.schedule = {current = 1, records = {
create_inactivity_order(depot_stop.backer_name),
create_loading_order(p_stop, manifest, p_enable_inactive),
create_unloading_order(r_stop, r_enable_inactive),
}}
lock_train(train)
send_alert_station_of_train_broken(map_data, train)
return true
end
if same_depot and not depot_stop.connected_rail then
--NOTE: create a schedule that cannot be fulfilled, the train will be stuck but it will give the player information what went wrong
train.schedule = {current = 1, records = {
create_inactivity_order(depot_stop.backer_name),
create_loading_order(p_stop, manifest, p_enable_inactive),
create_unloading_order(r_stop, r_enable_inactive),
}}
lock_train(train)
send_alert_depot_of_train_broken(map_data, train)
return true
end
local old_schedule
if not start_at_depot then
old_schedule = train.schedule
@@ -269,6 +292,11 @@ function add_refueler_schedule(map_data, train, stop)
schedule.current = i
end
if not stop.connected_rail then
send_alert_refueler_of_train_broken(map_data, train)
return false
end
local t_surface = train.front_stock.surface
local f_surface = stop.surface
local t_surface_i = t_surface.index
@@ -279,7 +307,7 @@ function add_refueler_schedule(map_data, train, stop)
table_insert(schedule.records, i, create_inactivity_order(stop.backer_name))
train.schedule = schedule
return
return true
elseif IS_SE_PRESENT then
local t_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = t_surface_i})--[[@as {}]]
local other_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = f_surface_i})--[[@as {}]]
@@ -302,7 +330,7 @@ function add_refueler_schedule(map_data, train, stop)
end
train.schedule = schedule
return
return true
end
end
--create an order that probably cannot be fulfilled and alert the player

View File

@@ -161,21 +161,23 @@ local migrations_table = {
settings.global["cybersyn-invert-sign"] = setting
for id, comb in pairs(map_data.to_comb) do
local control = get_comb_control(comb)
local params = control.parameters
local params_old = map_data.to_comb_params[id]
local bits = params.second_constant or 0
local bits_old = params_old.second_constant or 0
if comb.valid then
local control = get_comb_control(comb)
local params = control.parameters
local params_old = map_data.to_comb_params[id]
local bits = params.second_constant or 0
local bits_old = params_old.second_constant or 0
bits = bit32.replace(bits, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
bits = bit32.replace(bits, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
params.second_constant = bits
params_old.second_constant = bits_old
bits = bit32.replace(bits, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
bits = bit32.replace(bits, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
params.second_constant = bits
params_old.second_constant = bits_old
control.parameters = params
map_data.to_comb_params[id] = params_old
control.parameters = params
map_data.to_comb_params[id] = params_old
end
end
for _, station in pairs(map_data.stations) do
station.enable_inactive = true
@@ -239,19 +241,21 @@ local migrations_table = {
settings.global["cybersyn-invert-sign"] = setting
for id, comb in pairs(map_data.to_comb) do
local control = get_comb_control(comb)
local params = control.parameters
local params_old = map_data.to_comb_params[id]
local bits = params.second_constant or 0
local bits_old = params_old.second_constant or 0
if comb.valid then
local control = get_comb_control(comb)
local params = control.parameters
local params_old = map_data.to_comb_params[id]
local bits = params.second_constant or 0
local bits_old = params_old.second_constant or 0
bits = bit32.replace(bits, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
params.second_constant = bits
params_old.second_constant = bits_old
bits = bit32.replace(bits, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
params.second_constant = bits
params_old.second_constant = bits_old
control.parameters = params
map_data.to_comb_params[id] = params_old
control.parameters = params
map_data.to_comb_params[id] = params_old
end
end
for train_id, train in pairs(map_data.trains) do
train.use_any_depot = true

View File

@@ -355,13 +355,14 @@ local function on_train_leaves_stop(map_data, mod_settings, train_id, train)
end
end
if best_refueler_id then
train.status = STATUS_TO_F
train.refueler_id = best_refueler_id
local refueler = map_data.refuelers[best_refueler_id]
refueler.trains_total = refueler.trains_total + 1
add_refueler_schedule(map_data, train.entity, refueler.entity_stop)
interface_raise_train_status_changed(train_id, STATUS_R, STATUS_TO_F)
return
if add_refueler_schedule(map_data, train.entity, refueler.entity_stop) then
train.status = STATUS_TO_F
train.refueler_id = best_refueler_id
refueler.trains_total = refueler.trains_total + 1
interface_raise_train_status_changed(train_id, STATUS_R, STATUS_TO_F)
return
end
end
end
end