From 32ba29c55f323b109b19acef74b05e2beed0123a Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:08:18 -0500 Subject: [PATCH 1/7] switched to script --- cybersyn/scripts/main.lua | 51 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 21ce8da..eb67dc6 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -1,5 +1,4 @@ --By Mami -local flib_event = require("__flib__.event") local floor = math.floor local ceil = math.ceil local table_insert = table.insert @@ -938,10 +937,10 @@ local function on_settings_changed(event) mod_settings.warmup_time = settings.global["cybersyn-warmup-time"].value--[[@as double]] mod_settings.stuck_train_time = settings.global["cybersyn-stuck-train-time"].value--[[@as double]] if event.setting == "cybersyn-ticks-per-second" then - flib_event.on_nth_tick(nil) + script.on_nth_tick(nil) if mod_settings.tps > DELTA then - local nth_tick = ceil(60/mod_settings.tps); - flib_event.on_nth_tick(nth_tick, function() + local nth_tick = ceil(60/mod_settings.tps)--[[@as uint]]; + script.on_nth_tick(nth_tick, function() tick(global, mod_settings) end) end @@ -980,51 +979,51 @@ local function main() mod_settings.react_to_train_early_to_depot = true --NOTE: There is a concern that it is possible to build or destroy important entities without one of these events being triggered, in which case the mod will have undefined behavior - flib_event.register(defines.events.on_built_entity, on_built, filter_built) - flib_event.register(defines.events.on_robot_built_entity, on_built, filter_built) - flib_event.register({defines.events.script_raised_built, defines.events.script_raised_revive, defines.events.on_entity_cloned}, on_built) + script.on_event(defines.events.on_built_entity, on_built, filter_built) + script.on_event(defines.events.on_robot_built_entity, on_built, filter_built) + script.on_event({defines.events.script_raised_built, defines.events.script_raised_revive, defines.events.on_entity_cloned}, on_built) - flib_event.register(defines.events.on_player_rotated_entity, on_rotate) + script.on_event(defines.events.on_player_rotated_entity, on_rotate) - flib_event.register(defines.events.on_pre_player_mined_item, on_broken, filter_broken) - flib_event.register(defines.events.on_robot_pre_mined, on_broken, filter_broken) - flib_event.register(defines.events.on_entity_died, on_broken, filter_broken) - flib_event.register(defines.events.script_raised_destroy, on_broken) + script.on_event(defines.events.on_pre_player_mined_item, on_broken, filter_broken) + script.on_event(defines.events.on_robot_pre_mined, on_broken, filter_broken) + script.on_event(defines.events.on_entity_died, on_broken, filter_broken) + script.on_event(defines.events.script_raised_destroy, on_broken) - flib_event.register({defines.events.on_pre_surface_deleted, defines.events.on_pre_surface_cleared}, on_surface_removed) + script.on_event({defines.events.on_pre_surface_deleted, defines.events.on_pre_surface_cleared}, on_surface_removed) - flib_event.register(defines.events.on_entity_settings_pasted, on_paste) + script.on_event(defines.events.on_entity_settings_pasted, on_paste) if mod_settings.tps > DELTA then - local nth_tick = ceil(60/mod_settings.tps); - flib_event.on_nth_tick(nth_tick, function() + local nth_tick = ceil(60/mod_settings.tps)--[[@as uint]]; + script.on_nth_tick(nth_tick, function() tick(global, mod_settings) end) else - flib_event.on_nth_tick(nil) + script.on_nth_tick(nil) end - flib_event.register(defines.events.on_train_created, on_train_built) - flib_event.register(defines.events.on_train_changed_state, on_train_changed) + script.on_event(defines.events.on_train_created, on_train_built) + script.on_event(defines.events.on_train_changed_state, on_train_changed) - flib_event.register(defines.events.on_entity_renamed, on_rename) + script.on_event(defines.events.on_entity_renamed, on_rename) - flib_event.register(defines.events.on_runtime_mod_setting_changed, on_settings_changed) + script.on_event(defines.events.on_runtime_mod_setting_changed, on_settings_changed) register_gui_actions() - flib_event.on_init(init_global) + script.on_init(init_global) - flib_event.on_configuration_changed(on_config_changed) + script.on_configuration_changed(on_config_changed) if IS_SE_PRESENT then - flib_event.on_load(function() + script.on_load(function() local se_on_train_teleport_finished_event = remote.call("space-exploration", "get_on_train_teleport_finished_event") local se_on_train_teleport_started_event = remote.call("space-exploration", "get_on_train_teleport_started_event") - flib_event.register(se_on_train_teleport_started_event, function(event) + script.on_event(se_on_train_teleport_started_event, function(event) ---@type MapData local map_data = global local old_id = event.old_train_id_1 @@ -1039,7 +1038,7 @@ local function main() map_data.se_tele_old_id[train_unique_identifier] = old_id interface_raise_train_teleport_started(old_id) end) - flib_event.register(se_on_train_teleport_finished_event, function(event) + script.on_event(se_on_train_teleport_finished_event, function(event) ---@type MapData local map_data = global ---@type LuaTrain From 5462beb198e3d923db4501a8b200a1eb6367ee89 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:20:18 -0500 Subject: [PATCH 2/7] attempted fix --- cybersyn/scripts/global.lua | 5 +- cybersyn/scripts/main.lua | 152 ++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 77 deletions(-) diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index 532ffb0..e193d68 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -98,8 +98,8 @@ ---@alias cybersyn.global MapData ---@type CybersynModSettings mod_settings = {} - -IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil +---@type boolean +IS_SE_PRESENT = nil function init_global() global.total_ticks = 0 @@ -124,6 +124,7 @@ function init_global() global.layout_train_count = {} global.layout_top_id = 1 + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil if IS_SE_PRESENT then global.se_tele_old_id = {} end diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index eb67dc6..6386a1f 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -1017,95 +1017,97 @@ local function main() script.on_configuration_changed(on_config_changed) - if IS_SE_PRESENT then - script.on_load(function() - local se_on_train_teleport_finished_event = remote.call("space-exploration", "get_on_train_teleport_finished_event") - local se_on_train_teleport_started_event = remote.call("space-exploration", "get_on_train_teleport_started_event") + script.on_load(function() + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil + if not IS_SE_PRESENT then return end + local se_on_train_teleport_finished_event = remote.call("space-exploration", "get_on_train_teleport_finished_event") + local se_on_train_teleport_started_event = remote.call("space-exploration", "get_on_train_teleport_started_event") - script.on_event(se_on_train_teleport_started_event, function(event) - ---@type MapData - local map_data = global - local old_id = event.old_train_id_1 - --NOTE: this is not guaranteed to be unique, it should be fine since the window of time for another train to mistakenly steal this train's event data is miniscule - --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id - local train_unique_identifier = event.train.front_stock.backer_name + ---@param event {} + script.on_event(se_on_train_teleport_started_event, function(event) + ---@type MapData + local map_data = global + local old_id = event.old_train_id_1 + --NOTE: this is not guaranteed to be unique, it should be fine since the window of time for another train to mistakenly steal this train's event data is miniscule + --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id + local train_unique_identifier = event.train.front_stock.backer_name - local train = map_data.trains[old_id] - if not train then return end - --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished - train.se_is_being_teleported = true - map_data.se_tele_old_id[train_unique_identifier] = old_id - interface_raise_train_teleport_started(old_id) - end) - script.on_event(se_on_train_teleport_finished_event, function(event) - ---@type MapData - local map_data = global - ---@type LuaTrain - local train_entity = event.train - ---@type uint - local new_id = train_entity.id - local old_surface_index = event.old_surface_index - local train_unique_identifier = event.train.front_stock.backer_name + local train = map_data.trains[old_id] + if not train then return end + --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished + train.se_is_being_teleported = true + map_data.se_tele_old_id[train_unique_identifier] = old_id + interface_raise_train_teleport_started(old_id) + end) + ---@param event {} + script.on_event(se_on_train_teleport_finished_event, function(event) + ---@type MapData + local map_data = global + ---@type LuaTrain + local train_entity = event.train + ---@type uint + local new_id = train_entity.id + local old_surface_index = event.old_surface_index + local train_unique_identifier = event.train.front_stock.backer_name - --NOTE: event.old_train_id_1 from this event is useless, it's for one of the many transient trains SE spawns while teleporting the old train, only se_on_train_teleport_started_event returns the correct old train id - --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id - local old_id = map_data.se_tele_old_id[train_unique_identifier] - map_data.se_tele_old_id[train_unique_identifier] = nil - local train = map_data.trains[old_id] - if not train then return end + --NOTE: event.old_train_id_1 from this event is useless, it's for one of the many transient trains SE spawns while teleporting the old train, only se_on_train_teleport_started_event returns the correct old train id + --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id + local old_id = map_data.se_tele_old_id[train_unique_identifier] + map_data.se_tele_old_id[train_unique_identifier] = nil + local train = map_data.trains[old_id] + if not train then return end - if train.is_available then - local network = map_data.available_trains[train.network_name--[[@as string]]] - if network then - network[new_id] = true - network[old_id] = nil - end + if train.is_available then + local network = map_data.available_trains[train.network_name--[[@as string]]] + if network then + network[new_id] = true + network[old_id] = nil end + end - map_data.trains[new_id] = train - map_data.trains[old_id] = nil - train.se_is_being_teleported = nil - train.entity = train_entity + map_data.trains[new_id] = train + map_data.trains[old_id] = nil + train.se_is_being_teleported = nil + train.entity = train_entity - if train.se_awaiting_removal then - remove_train(map_data, train.se_awaiting_removal, train) - lock_train(train.entity) - send_lost_train_alert(train.entity, train.depot_name) - return - elseif train.se_awaiting_rename then - rename_manifest_schedule(train.entity, train.se_awaiting_rename[1], train.se_awaiting_rename[2]) - train.se_awaiting_rename = nil - end + if train.se_awaiting_removal then + remove_train(map_data, train.se_awaiting_removal, train) + lock_train(train.entity) + send_lost_train_alert(train.entity, train.depot_name) + return + elseif train.se_awaiting_rename then + rename_manifest_schedule(train.entity, train.se_awaiting_rename[1], train.se_awaiting_rename[2]) + train.se_awaiting_rename = nil + end - if not (train.status == STATUS_D_TO_P or train.status == STATUS_P_TO_R) then return end + if not (train.status == STATUS_D_TO_P or train.status == STATUS_P_TO_R) then return end - local schedule = train_entity.schedule - if schedule then - local p_station = map_data.stations[train.p_station_id] - local p_name = p_station.entity_stop.backer_name - local p_surface_i = p_station.entity_stop.surface.index - local r_station = map_data.stations[train.r_station_id] - local r_name = r_station.entity_stop.backer_name - local r_surface_i = r_station.entity_stop.surface.index - local records = schedule.records - local i = schedule.current - while i <= #records do - if records[i].station == p_name and p_surface_i ~= old_surface_index then - table_insert(records, i, create_direct_to_station_order(p_station.entity_stop)) - i = i + 1 - elseif records[i].station == r_name and r_surface_i ~= old_surface_index then - table_insert(records, i, create_direct_to_station_order(r_station.entity_stop)) - i = i + 1 - end + local schedule = train_entity.schedule + if schedule then + local p_station = map_data.stations[train.p_station_id] + local p_name = p_station.entity_stop.backer_name + local p_surface_i = p_station.entity_stop.surface.index + local r_station = map_data.stations[train.r_station_id] + local r_name = r_station.entity_stop.backer_name + local r_surface_i = r_station.entity_stop.surface.index + local records = schedule.records + local i = schedule.current + while i <= #records do + if records[i].station == p_name and p_surface_i ~= old_surface_index then + table_insert(records, i, create_direct_to_station_order(p_station.entity_stop)) + i = i + 1 + elseif records[i].station == r_name and r_surface_i ~= old_surface_index then + table_insert(records, i, create_direct_to_station_order(r_station.entity_stop)) i = i + 1 end - train_entity.schedule = schedule + i = i + 1 end - interface_raise_train_teleported(new_id, old_id) - end) + train_entity.schedule = schedule + end + interface_raise_train_teleported(new_id, old_id) end) - end + end) end From 899669baa1c1dfe3e514580248a654b5d20bcb39 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:33:30 -0500 Subject: [PATCH 3/7] attempted fix --- cybersyn/scripts/global.lua | 1 - cybersyn/scripts/main.lua | 190 ++++++++++++++++++------------------ 2 files changed, 97 insertions(+), 94 deletions(-) diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index e193d68..d7de169 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -124,7 +124,6 @@ function init_global() global.layout_train_count = {} global.layout_top_id = 1 - IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil if IS_SE_PRESENT then global.se_tele_old_id = {} end diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 6386a1f..c2fb777 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -947,6 +947,98 @@ local function on_settings_changed(event) end end +local function setup_se_compat() + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil + if not IS_SE_PRESENT then return end + + local se_on_train_teleport_finished_event = remote.call("space-exploration", "get_on_train_teleport_finished_event") + local se_on_train_teleport_started_event = remote.call("space-exploration", "get_on_train_teleport_started_event") + + ---@param event {} + script.on_event(se_on_train_teleport_started_event, function(event) + ---@type MapData + local map_data = global + local old_id = event.old_train_id_1 + --NOTE: this is not guaranteed to be unique, it should be fine since the window of time for another train to mistakenly steal this train's event data is miniscule + --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id + local train_unique_identifier = event.train.front_stock.backer_name + + local train = map_data.trains[old_id] + if not train then return end + --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished + train.se_is_being_teleported = true + map_data.se_tele_old_id[train_unique_identifier] = old_id + interface_raise_train_teleport_started(old_id) + end) + ---@param event {} + script.on_event(se_on_train_teleport_finished_event, function(event) + ---@type MapData + local map_data = global + ---@type LuaTrain + local train_entity = event.train + ---@type uint + local new_id = train_entity.id + local old_surface_index = event.old_surface_index + local train_unique_identifier = event.train.front_stock.backer_name + + --NOTE: event.old_train_id_1 from this event is useless, it's for one of the many transient trains SE spawns while teleporting the old train, only se_on_train_teleport_started_event returns the correct old train id + --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id + local old_id = map_data.se_tele_old_id[train_unique_identifier] + map_data.se_tele_old_id[train_unique_identifier] = nil + local train = map_data.trains[old_id] + if not train then return end + + if train.is_available then + local network = map_data.available_trains[train.network_name--[[@as string]]] + if network then + network[new_id] = true + network[old_id] = nil + end + end + + map_data.trains[new_id] = train + map_data.trains[old_id] = nil + train.se_is_being_teleported = nil + train.entity = train_entity + + if train.se_awaiting_removal then + remove_train(map_data, train.se_awaiting_removal, train) + lock_train(train.entity) + send_lost_train_alert(train.entity, train.depot_name) + return + elseif train.se_awaiting_rename then + rename_manifest_schedule(train.entity, train.se_awaiting_rename[1], train.se_awaiting_rename[2]) + train.se_awaiting_rename = nil + end + + if not (train.status == STATUS_D_TO_P or train.status == STATUS_P_TO_R) then return end + + local schedule = train_entity.schedule + if schedule then + local p_station = map_data.stations[train.p_station_id] + local p_name = p_station.entity_stop.backer_name + local p_surface_i = p_station.entity_stop.surface.index + local r_station = map_data.stations[train.r_station_id] + local r_name = r_station.entity_stop.backer_name + local r_surface_i = r_station.entity_stop.surface.index + local records = schedule.records + local i = schedule.current + while i <= #records do + if records[i].station == p_name and p_surface_i ~= old_surface_index then + table_insert(records, i, create_direct_to_station_order(p_station.entity_stop)) + i = i + 1 + elseif records[i].station == r_name and r_surface_i ~= old_surface_index then + table_insert(records, i, create_direct_to_station_order(r_station.entity_stop)) + i = i + 1 + end + i = i + 1 + end + train_entity.schedule = schedule + end + interface_raise_train_teleported(new_id, old_id) + end) +end + local filter_built = { {filter = "name", name = "train-stop"}, @@ -1012,102 +1104,14 @@ local function main() register_gui_actions() - script.on_init(init_global) + script.on_init(function() + setup_se_compat() + init_global() + end) script.on_configuration_changed(on_config_changed) - - script.on_load(function() - IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil - if not IS_SE_PRESENT then return end - - local se_on_train_teleport_finished_event = remote.call("space-exploration", "get_on_train_teleport_finished_event") - local se_on_train_teleport_started_event = remote.call("space-exploration", "get_on_train_teleport_started_event") - - ---@param event {} - script.on_event(se_on_train_teleport_started_event, function(event) - ---@type MapData - local map_data = global - local old_id = event.old_train_id_1 - --NOTE: this is not guaranteed to be unique, it should be fine since the window of time for another train to mistakenly steal this train's event data is miniscule - --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id - local train_unique_identifier = event.train.front_stock.backer_name - - local train = map_data.trains[old_id] - if not train then return end - --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished - train.se_is_being_teleported = true - map_data.se_tele_old_id[train_unique_identifier] = old_id - interface_raise_train_teleport_started(old_id) - end) - ---@param event {} - script.on_event(se_on_train_teleport_finished_event, function(event) - ---@type MapData - local map_data = global - ---@type LuaTrain - local train_entity = event.train - ---@type uint - local new_id = train_entity.id - local old_surface_index = event.old_surface_index - local train_unique_identifier = event.train.front_stock.backer_name - - --NOTE: event.old_train_id_1 from this event is useless, it's for one of the many transient trains SE spawns while teleporting the old train, only se_on_train_teleport_started_event returns the correct old train id - --NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id - local old_id = map_data.se_tele_old_id[train_unique_identifier] - map_data.se_tele_old_id[train_unique_identifier] = nil - local train = map_data.trains[old_id] - if not train then return end - - if train.is_available then - local network = map_data.available_trains[train.network_name--[[@as string]]] - if network then - network[new_id] = true - network[old_id] = nil - end - end - - map_data.trains[new_id] = train - map_data.trains[old_id] = nil - train.se_is_being_teleported = nil - train.entity = train_entity - - if train.se_awaiting_removal then - remove_train(map_data, train.se_awaiting_removal, train) - lock_train(train.entity) - send_lost_train_alert(train.entity, train.depot_name) - return - elseif train.se_awaiting_rename then - rename_manifest_schedule(train.entity, train.se_awaiting_rename[1], train.se_awaiting_rename[2]) - train.se_awaiting_rename = nil - end - - if not (train.status == STATUS_D_TO_P or train.status == STATUS_P_TO_R) then return end - - local schedule = train_entity.schedule - if schedule then - local p_station = map_data.stations[train.p_station_id] - local p_name = p_station.entity_stop.backer_name - local p_surface_i = p_station.entity_stop.surface.index - local r_station = map_data.stations[train.r_station_id] - local r_name = r_station.entity_stop.backer_name - local r_surface_i = r_station.entity_stop.surface.index - local records = schedule.records - local i = schedule.current - while i <= #records do - if records[i].station == p_name and p_surface_i ~= old_surface_index then - table_insert(records, i, create_direct_to_station_order(p_station.entity_stop)) - i = i + 1 - elseif records[i].station == r_name and r_surface_i ~= old_surface_index then - table_insert(records, i, create_direct_to_station_order(r_station.entity_stop)) - i = i + 1 - end - i = i + 1 - end - train_entity.schedule = schedule - end - interface_raise_train_teleported(new_id, old_id) - end) - end) + script.on_load(setup_se_compat) end From 5918437aefa1c9751e4370981288f89d67c61c32 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:34:25 -0500 Subject: [PATCH 4/7] fix --- cybersyn/scripts/global.lua | 1 + cybersyn/scripts/migrations.lua | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index d7de169..e193d68 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -124,6 +124,7 @@ function init_global() global.layout_train_count = {} global.layout_top_id = 1 + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil if IS_SE_PRESENT then global.se_tele_old_id = {} end diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index b7caa98..df7365b 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -189,6 +189,8 @@ local migrations_table = { ---@param data ConfigurationChangedData function on_config_changed(data) flib_migration.on_config_changed(data, migrations_table) + + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil if IS_SE_PRESENT and not global.se_tele_old_id then global.se_tele_old_id = {} end From 5dc931f4e98504de815994fe7db81942dc078ba7 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:37:17 -0500 Subject: [PATCH 5/7] changed design --- cybersyn/scripts/main.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index c2fb777..4137197 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -1111,7 +1111,9 @@ local function main() script.on_configuration_changed(on_config_changed) - script.on_load(setup_se_compat) + script.on_load(function() + setup_se_compat() + end) end From aac5d85ebdd4aa09a58c8eeea6bda8307e8028d1 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:41:00 -0500 Subject: [PATCH 6/7] added minor fix --- cybersyn/scripts/main.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 4137197..ec434d0 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -937,12 +937,13 @@ local function on_settings_changed(event) mod_settings.warmup_time = settings.global["cybersyn-warmup-time"].value--[[@as double]] mod_settings.stuck_train_time = settings.global["cybersyn-stuck-train-time"].value--[[@as double]] if event.setting == "cybersyn-ticks-per-second" then - script.on_nth_tick(nil) if mod_settings.tps > DELTA then local nth_tick = ceil(60/mod_settings.tps)--[[@as uint]]; script.on_nth_tick(nth_tick, function() tick(global, mod_settings) end) + else + script.on_nth_tick(nil) end end end @@ -1105,8 +1106,8 @@ local function main() register_gui_actions() script.on_init(function() - setup_se_compat() init_global() + setup_se_compat() end) script.on_configuration_changed(on_config_changed) From 511b90527d993d89092b45cdea1745d425676865 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 21:46:34 -0500 Subject: [PATCH 7/7] updated version --- cybersyn/changelog.txt | 5 +++++ cybersyn/info.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index 1fa9cc0..2ecbabd 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -106,3 +106,8 @@ Date: 2022-12-2 - Fixed a bug with combinator displays not updating correctly - Improved combinator display performance - Added a modding interface +--------------------------------------------------------------------------------------------------- +Version: 1.0.9 +Date: 2022-12-3 + Features: + - Fixed a bug with SE compat preventing players from joining multiplayer games diff --git a/cybersyn/info.json b/cybersyn/info.json index 5289cc9..1c35137 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "1.0.8", + "version": "1.0.9", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1",