Check disconnect in thread

Simple and convenient check: it slows down the script in case of disconnect, and continues its work when the connection is restored

procedure CheckDisconnectThread();
begin
  while delay(100) do begin
    if (Engine.Status <> lsOnline) then begin
      Print('Disconnect, pausing the script');
      Script.Suspend;
      while (Engine.Status <> lsOnline) do delay(100);
      Print('Hey, Im in the game, continue to work');
      Script.Resume;
    end;
  end;
end;

begin
  Script.NewThread(@CheckDisconnectThread);
  // code
end.