Skip to content

Commit

Permalink
Merge pull request #233 from ILLISIS/v2.0.11
Browse files Browse the repository at this point in the history
v2.0.11
  • Loading branch information
ILLISIS authored Nov 10, 2024
2 parents 4fb0f81 + c2d8b29 commit 2ccb262
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
7 changes: 4 additions & 3 deletions script/entity_processor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions script/job/upgrade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 24 additions & 17 deletions script/ui_settings_screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,20 @@ 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",
column_count = 2,
}

-- 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",
Expand All @@ -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",
Expand All @@ -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],
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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],
Expand All @@ -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",
Expand Down

0 comments on commit 2ccb262

Please sign in to comment.