From 915ed0b0f28cfb02f22d5581b607f329c31d5807 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Sat, 17 Dec 2022 11:48:35 -0500 Subject: [PATCH 1/3] fixed false positive bug --- .luarc.json | 3 ++- cybersyn/changelog.txt | 5 +++++ cybersyn/scripts/main.lua | 39 ++++++++++++++++++++++++--------------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.luarc.json b/.luarc.json index 7924b4d..205bdad 100644 --- a/.luarc.json +++ b/.luarc.json @@ -14,6 +14,7 @@ "__Profiler", "create_inactivity_order" ], + "Lua.workspace.checkThirdParty": false, "runtime": { "plugin": "C:\\Users\\mmoni\\files\\data\\projects\\factorio\\cybersyn\\.vscode\\lua\\plugin.lua", "pluginArgs": [ @@ -35,4 +36,4 @@ "useGitIgnore": false }, "workspace.ignoreSubmodules": false -} +} \ No newline at end of file diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index d26cafe..5c8f108 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 1.1.7 +Date: 2022-12-17 + Changes: + - Fixed false positives in copy-paste by blueprint detection logic +--------------------------------------------------------------------------------------------------- Version: 1.1.6 Date: 2022-12-16 Changes: diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 116f7f3..0e6a933 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -398,24 +398,33 @@ function combinator_update(map_data, comb, reset_display) local params = control.parameters local old_params = map_data.to_comb_params[unit_number] local has_changed = false + local station + local id - local stop = map_data.to_stop[comb.unit_number] - if reset_display and 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 - if station.display_state >= 2 then - params.operation = MODE_PRIMARY_IO_ACTIVE - elseif station.display_state == 1 then - params.operation = MODE_PRIMARY_IO_FAILED_REQUEST - else - params.operation = MODE_PRIMARY_IO + + if params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST or params.operation == MODE_PRIMARY_IO then + --the follow is only present to fix combinators that have been copy-pasted by blueprint with the wrong operation + local stop = map_data.to_stop[comb.unit_number--[[@as uint]]] + if stop then + id = stop.unit_number--[[@as uint]] + station = map_data.stations[id] + if reset_display then + if station and station.entity_comb1 == comb then + --make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params + if station.display_state >= 2 then + params.operation = MODE_PRIMARY_IO_ACTIVE + elseif station.display_state == 1 then + params.operation = MODE_PRIMARY_IO_FAILED_REQUEST + else + params.operation = MODE_PRIMARY_IO + end + control.parameters = params + else + params.operation = MODE_PRIMARY_IO + control.parameters = params + end end - control.parameters = params 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 From 25d386fcd96fd8e2a417d368cdfdd34cf660800c Mon Sep 17 00:00:00 2001 From: mamoniot Date: Sat, 17 Dec 2022 11:58:44 -0500 Subject: [PATCH 2/3] fixed bug --- cybersyn/scripts/main.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 0e6a933..79261fb 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -405,26 +405,27 @@ function combinator_update(map_data, comb, reset_display) if params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST or params.operation == MODE_PRIMARY_IO then --the follow is only present to fix combinators that have been copy-pasted by blueprint with the wrong operation local stop = map_data.to_stop[comb.unit_number--[[@as uint]]] + local should_reset = reset_display if stop then id = stop.unit_number--[[@as uint]] station = map_data.stations[id] - if reset_display then - if station and station.entity_comb1 == comb then - --make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params - if station.display_state >= 2 then - params.operation = MODE_PRIMARY_IO_ACTIVE - elseif station.display_state == 1 then - params.operation = MODE_PRIMARY_IO_FAILED_REQUEST - else - params.operation = MODE_PRIMARY_IO - end - control.parameters = params + if should_reset and station and station.entity_comb1 == comb then + --make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params + if station.display_state >= 2 then + params.operation = MODE_PRIMARY_IO_ACTIVE + elseif station.display_state == 1 then + params.operation = MODE_PRIMARY_IO_FAILED_REQUEST else params.operation = MODE_PRIMARY_IO - control.parameters = params end + control.parameters = params + should_reset = false end end + if should_reset then + params.operation = MODE_PRIMARY_IO + control.parameters = params + end params.operation = MODE_PRIMARY_IO end if params.operation ~= old_params.operation then From 2169ebb1016af812a1ccf002c7e8434f9c15b8de Mon Sep 17 00:00:00 2001 From: mamoniot Date: Sat, 17 Dec 2022 12:08:49 -0500 Subject: [PATCH 3/3] fixed version --- TODO | 1 + cybersyn/info.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 16aecf9..909d8bd 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,7 @@ major: models & art move to an event based algorithm debug output + more detailed missing train alerts minor: railloader compat diff --git a/cybersyn/info.json b/cybersyn/info.json index 91518b3..ac57f6b 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "1.1.6", + "version": "1.1.7", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1",