diff --git a/changelog.txt b/changelog.txt index c55267b..9dfbb17 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,12 @@ +--------------------------------------------------------------------------------------------------- +Version: 2.0.11 +Date: 2024-11-10 + Changes: + - Added the ability to select construction robots added by other mods. + Bugfixes: + - Fixed entity processsing for upgrade jobs selecting the original item quality rather than the upgrade target quality. + - Fixed that upgrade jobs would check for the wrong item quality when determining if the job is complete. + --------------------------------------------------------------------------------------------------- Version: 2.0.10 Date: 2024-11-07 diff --git a/info.json b/info.json index cd81977..94b1fd8 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "Constructron-Continued", - "version": "2.0.10", + "version": "2.0.11", "title": "Constructron-Continued", "author": "ILLISIS", "homepage": "https://github.com/ILLISIS/Constructron-continued/", diff --git a/script/entity_processor.lua b/script/entity_processor.lua index d9ff194..b7688bb 100644 --- a/script/entity_processor.lua +++ b/script/entity_processor.lua @@ -582,14 +582,15 @@ entity_proc.upgrade = function(entity) local target_entity, quality = entity.get_upgrade_target() ---@cast target_entity -nil ---@cast quality -nil - local quality_level = entity.quality.name + local target_quality_level = quality.name + local current_quality_level = entity.quality.name local old_entity_name = entity.name local items_to_place_cache = storage.items_to_place_cache[target_entity.name] local item_name = items_to_place_cache.item required_items[item_name] = required_items[item_name] or {} - required_items[item_name][quality_level] = (required_items[item_name][quality_level] or 0) + items_to_place_cache.count + required_items[item_name][target_quality_level] = (required_items[item_name][target_quality_level] or 0) + items_to_place_cache.count trash_items[old_entity_name] = trash_items[old_entity_name] or {} - trash_items[old_entity_name][quality_level] = (trash_items[old_entity_name][quality_level] or 0) + 1 + trash_items[old_entity_name][current_quality_level] = (trash_items[old_entity_name][current_quality_level] or 0) + 1 return required_items, trash_items end diff --git a/script/job/upgrade.lua b/script/job/upgrade.lua index 7790d0b..93f0f60 100644 --- a/script/job/upgrade.lua +++ b/script/job/upgrade.lua @@ -21,8 +21,8 @@ function upgrade_job:specific_action() } -- only detects entities in range local can_upgrade_entity = false for _, entity in pairs(entities) do - local target = entity.get_upgrade_target() ---@cast target -nil - if self.worker_logistic_network.can_satisfy_request(target.items_to_place_this[1].name, 1) then -- does inventory have the required item? + local target, target_quality = entity.get_upgrade_target() ---@cast target -nil + if self.worker_logistic_network.can_satisfy_request({name = target.name, quality = target_quality}, 1, false) then -- does inventory have the required item? can_upgrade_entity = true end end diff --git a/script/ui_settings_screen.lua b/script/ui_settings_screen.lua index fb0545d..6687616 100644 --- a/script/ui_settings_screen.lua +++ b/script/ui_settings_screen.lua @@ -274,7 +274,7 @@ function gui_settings.buildSettingsContent(player, surface, frame) ignored_by_interaction = true } - local table = frame.add{ + local settings_table = frame.add{ type = "table", name = "ctron_surface_settings_table", style = "ctron_settings_table_style", @@ -282,12 +282,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) } -- robot count - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_robot_count_label"}, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "textfield", text = storage.desired_robot_count[surface_index], style = "ctron_settings_textfield_style", @@ -301,19 +301,26 @@ function gui_settings.buildSettingsContent(player, surface, frame) setting_surface = surface_index } } - -- robot selection - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_robot_selection_label"}, tooltip = {"ctron_gui_locale.settings_robot_selection_tooltip"}, style = "ctron_settings_label_style" } - table.add{ + + local robot_items = {} + for _, robot in pairs(prototypes.get_entity_filtered{{filter = "type", type = "construction-robot"}}) do + if robot.items_to_place_this ~= nil and robot.items_to_place_this[1] and robot.items_to_place_this[1].name then + local item = robot.items_to_place_this[1] + table.insert(robot_items, item.name) + end + end + settings_table.add{ type = "choose-elem-button", elem_type = "item-with-quality", ["item-with-quality"] = storage.desired_robot_name[surface_index], - elem_filters = {{filter = "name", name = "construction-robot"}}, + elem_filters = {{filter = "name", name = robot_items}}, tags = { mod = "constructron", on_gui_elem_changed = "select_new_robot", @@ -323,12 +330,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) -- job toggles for setting_name, setting_params in pairs(toggle_settings) do - table.add{ + settings_table.add{ type = "label", caption = setting_params.label, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "checkbox", name = "ctron_" .. setting_name .. "_toggle", state = storage[setting_name .. "_job_toggle"][surface_index], @@ -343,12 +350,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) end -- ammo selection - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_ammo_selection_label"}, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "choose-elem-button", name = "ctron_ammo_select", elem_type = "item-with-quality", @@ -362,12 +369,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) } -- ammo count - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_ammo_count_label"}, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "textfield", text = storage.ammo_count[surface_index], style = "ctron_settings_textfield_style", @@ -383,12 +390,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) } -- repair job toggle - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_repair_jobs_label"}, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "checkbox", name = "ctron_repair_toggle", state = storage.repair_job_toggle[surface_index], @@ -402,12 +409,12 @@ function gui_settings.buildSettingsContent(player, surface, frame) } -- repair tool selection - table.add{ + settings_table.add{ type = "label", caption = {"ctron_gui_locale.settings_repair_tool_selection_label"}, style = "ctron_settings_label_style" } - table.add{ + settings_table.add{ type = "choose-elem-button", -- style = "", elem_type = "item-with-quality",