@@ -110,17 +110,19 @@ function blackHoleController:new(
110110 end
111111 end
112112 self .stateMachine .states .idle .update = function ()
113- if self :hasItems () == true and self .controllerProxy .isWorkAllowed () then
114- if self :hasSeeds () == true then
115- if self :hasEnoughSpacetime (self .stateMachine .data .spaceTimePerCraftCount ) then
116- self .stateMachine :setState (self .stateMachine .states .openBlackHole )
117- return
118- elseif self .stateMachine .data .notifyNotEnoughSpaceTime == false then
119- self .stateMachine .data .notifyNotEnoughSpaceTime = true
120- event .push (" log_warning" , " Not enough Space Time for craft. Need: " .. numWithCommas (self .stateMachine .data .spaceTimePerCraftCount ))
113+ if self .controllerProxy .getWorkMaxProgress () == 0 then
114+ if self :hasItems () == true and self .controllerProxy .isWorkAllowed () then
115+ if self :hasSeeds () == true then
116+ if self :hasEnoughSpacetime (self .stateMachine .data .spaceTimePerCraftCount ) then
117+ self .stateMachine :setState (self .stateMachine .states .openBlackHole )
118+ return
119+ elseif self .stateMachine .data .notifyNotEnoughSpaceTime == false then
120+ self .stateMachine .data .notifyNotEnoughSpaceTime = true
121+ event .push (" log_warning" , " Not enough Space Time for craft. Need: " .. numWithCommas (self .stateMachine .data .spaceTimePerCraftCount ))
122+ end
123+
124+ os .sleep (3 )
121125 end
122-
123- os .sleep (3 )
124126 end
125127 end
126128 end
@@ -230,15 +232,23 @@ function blackHoleController:new(
230232 self .stateMachine .states .collapseBlackHole = self .stateMachine :createState (" Collapse Black Hole" )
231233 self .stateMachine .states .collapseBlackHole .init = function ()
232234 self :collapseBlackHole ()
235+ self .stateMachine :setState (self .stateMachine .states .waitEnd )
233236 end
234- self .stateMachine .states .collapseBlackHole .update = function ()
237+
238+ self .stateMachine .states .waitEnd = self .stateMachine :createState (" Wait end" )
239+ self .stateMachine .states .waitEnd .update = function ()
235240 if self .controllerProxy .getWorkMaxProgress () == 0 then
236241 self .stateMachine :setState (self .stateMachine .states .idle )
237242 end
238243 end
239244
240245 self .stateMachine .states .error = self .stateMachine :createState (" Error" )
241246 self .stateMachine .states .error .init = function ()
247+ self :collapseBlackHole ()
248+
249+ self .stateMachine .data .startTime = nil
250+ self .stateMachine .data .cycleStartTime = nil
251+
242252 while self :tryCancelFakeRecipe () == false do
243253 os .sleep (0.1 )
244254 end
@@ -268,7 +278,7 @@ function blackHoleController:new(
268278 -- Reset error
269279 function obj :resetError ()
270280 if self .stateMachine .currentState == self .stateMachine .states .error then
271- self .stateMachine :setState (self .stateMachine .states .idle )
281+ self .stateMachine :setState (self .stateMachine .states .waitEnd )
272282 end
273283 end
274284
0 commit comments