diff --git a/changelog.txt b/changelog.txt index 4031814..93ad193 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,8 +1,11 @@ --------------------------------------------------------------------------------------------------- Version: 2.0.14 Date: ???? + Changes: + - Added behavioural support for different landfill types like foundations and ice platforms. Bugfixes: - Fixed another crash during cargo job prospecting. + - Fixed an issue that caused Constructrons not to restart a landfill job if there were no items to build available when moving into position. --------------------------------------------------------------------------------------------------- Version: 2.0.13 Date: 2024-11-22 diff --git a/migrations/Constructron-Continued_2.0.14.lua b/migrations/Constructron-Continued_2.0.14.lua new file mode 100644 index 0000000..33b1842 --- /dev/null +++ b/migrations/Constructron-Continued_2.0.14.lua @@ -0,0 +1,11 @@ +-- set landfill type on existing jobs +for _, job in pairs(storage.jobs) do + if job.landfill_job then + job.landfill_type = "landfill" + end +end + + +------------------------------------------------------------------------------- + +game.print('Constructron-Continued: v2.0.14 migration complete!') \ No newline at end of file diff --git a/script/job.lua b/script/job.lua index 01d5d81..726caa4 100644 --- a/script/job.lua +++ b/script/job.lua @@ -757,6 +757,19 @@ function job:request_ammo() end end +local landfill_types = {"ice-platform", "foundation", "landfill"} + +-- flag the job as a landfill job if certain items are present in the jobs required_items +function job:check_if_landfilling() + for _, type in ipairs(landfill_types) do + if self.required_items[type] then + self.landfill_job = true + self.landfill_type = type + break + end + end +end + function job:calculate_task_positions() local worker = self.worker ---@cast worker -nil for _, chunk in pairs(self.chunks) do @@ -766,9 +779,6 @@ function job:calculate_task_positions() debug_lib.VisualDebugCircle(position, self.surface_index, "yellow", 0.5, 3600) table.insert(self.task_positions, position) end - if chunk.required_items["landfill"] then - self.landfill_job = true - end end end @@ -847,16 +857,13 @@ end -- State Logic --===========================================================================-- - - - - - function job:setup() -- calculate task positions self:calculate_task_positions() -- request ammo self:request_ammo() + -- check if landfilling + self:check_if_landfilling() -- state change self.state = "starting" end diff --git a/script/job/construction.lua b/script/job/construction.lua index 2df8b89..975d42e 100644 --- a/script/job/construction.lua +++ b/script/job/construction.lua @@ -25,7 +25,7 @@ function construction_job:position_check(position, distance) self:move_to_position(position) end else - if self.landfill_job and self.status == "in_progress" and not self.worker_logistic_network.can_satisfy_request("landfill", 1) then -- is this a landfill job and do we have landfill? + if self.landfill_job and self.state == "in_progress" and not self.worker_logistic_network.can_satisfy_request(self.landfill_type, 1) then -- is this a landfill job and do we have landfill? debug_lib.VisualDebugText("Job wrapup: No landfill", worker, -0.5, 5) worker.autopilot_destination = nil self:check_chunks()