Skip to content

Commit

Permalink
v2.0.14 commit 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ILLISIS committed Nov 27, 2024
1 parent 3be29d9 commit 2a0c342
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions migrations/Constructron-Continued_2.0.14.lua
Original file line number Diff line number Diff line change
@@ -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!')
23 changes: 15 additions & 8 deletions script/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion script/job/construction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2a0c342

Please sign in to comment.