@@ -48,6 +48,7 @@ unless specified otherwise.
4848 Name: String;
4949 Slots: TBoxArray;
5050 SlotsFunction: function (): TBoxArray of object;
51+ CheckFunction: function (): Boolean of object;
5152 end;
5253
5354(*
@@ -85,11 +86,12 @@ Bank.Slots.Setup('Bank.Slots', Bank.SlotBoxes, @Bank.FindItemBoundaries);
8586Just in case people would like to access the bank's static slots through it's
8687`Slots` variable.
8788*)
88- procedure TRSSlotInterface.Setup(name: String; slots: TBoxArray; slotsFunction: function (): TBoxArray of object = nil);
89+ procedure TRSSlotInterface.Setup(name: String; slots: TBoxArray; slotsFunction: function (): TBoxArray of object = nil; checkFunc: function (): Boolean of object = nil );
8990begin
9091 Self.Name := name;
9192 Self.Slots := slots;
9293 Self.SlotsFunction := @slotsFunction;
94+ Self.CheckFunction := @checkFunc;
9395end;
9496
9597(*
310312 slots: TBoxArray;
311313 i: Integer;
312314begin
315+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
316+ Exit;
313317 slots := Self.Boxes();
314318 for i := 0 to High(slots) do
315319 if Target.HasColor(TRSItem.Border, 8.5, 1, slots[i]) or
342346 slots: TBoxArray;
343347 i: Integer;
344348begin
349+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
350+ Exit;
345351 slots := Self.Boxes();
346352 for i := 0 to High(slots) do
347353 if not Target.HasColor(TRSItem.Border, 8.5, 1, slots[i]) and
@@ -368,12 +374,14 @@ end.
368374*)
369375function TRSSlotInterface.IsUsed(slot: TBox): Boolean;
370376begin
377+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
378+ Exit;
371379 Result := TRSItem.InBounds(slot);
372380end;
373381
374382function TRSSlotInterface.IsUsed(slot: Integer): Boolean; overload;
375383begin
376- Result := TRSItem.InBounds (Self.Box(slot));
384+ Result := Self.IsUsed (Self.Box(slot));
377385end;
378386
379387(*
@@ -394,12 +402,14 @@ end.
394402*)
395403function TRSSlotInterface.IsEmpty(slot: TBox): Boolean;
396404begin
405+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
406+ Exit;
397407 Result := not TRSItem.InBounds(slot);
398408end;
399409
400410function TRSSlotInterface.IsEmpty(slot: Integer): Boolean; overload;
401411begin
402- Result := not TRSItem.InBounds (Self.Box(slot));
412+ Result := Self.IsEmpty (Self.Box(slot));
403413end;
404414
405415
@@ -422,15 +432,16 @@ end.
422432*)
423433function TRSSlotInterface.IsFaded(slot: TBox): Boolean;
424434begin
435+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
436+ Exit;
425437 Result := not TRSItem.InBounds(slot, 0) and TRSItem.InBounds(slot);
426438end;
427439
428440function TRSSlotInterface.IsFaded(slot: Integer): Boolean; overload;
429- var
430- b: TBox;
431441begin
432- b := Self.Box(slot);
433- Result := not TRSItem.InBounds(b, 0) and TRSItem.InBounds(b);
442+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
443+ Exit;
444+ Result := Self.IsFaded(Self.Box(slot));
434445end;
435446
436447
452463*)
453464function TRSSlotInterface.WaitFade(slot: TBox; time: Integer = 200): Boolean;
454465begin
455- if not Self.IsFaded(slot) then Exit;
466+ if not Self.IsFaded(slot) then
467+ Exit;
456468 Result := SleepUntil(TRSItem.InBounds(slot, 0), 100, time);
457469end;
458470
@@ -550,12 +562,14 @@ end.
550562*)
551563function TRSSlotInterface.ReadStack(slot: TBox): Integer;
552564begin
565+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
566+ Exit;
553567 Result := TRSItem.ReadStack(slot);
554568end;
555569
556570function TRSSlotInterface.ReadStack(slot: Integer): Integer; overload;
557571begin
558- Result := TRSItem .ReadStack(Self.Box(slot));
572+ Result := Self .ReadStack(Self.Box(slot));
559573end;
560574
561575
597611*)
598612procedure TRSSlotInterface.Click(slot: Integer; button: EMouseButton = EMouseButton.LEFT);
599613begin
614+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
615+ Exit;
600616 Self.Hover(slot);
601617 Target.MouseClick(button);
602618end;
@@ -621,7 +637,11 @@ function TRSSlotInterface.Move(slot, destination: Integer): Boolean;
621637var
622638 slots: TBoxArray;
623639begin
624- if slot = destination then Exit(True);
640+ if slot = destination then
641+ Exit(True);
642+
643+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
644+ Exit;
625645
626646 slots := Self.Boxes([slot, destination]);
627647
657677*)
658678function TRSSlotInterface.Interact(slot: Integer; option: String = ''): Boolean;
659679begin
680+ if (@Self.CheckFunction <> nil) and not Self.CheckFunction() then
681+ Exit;
660682 Self.Hover(slot);
661683
662684 if (option <> '') and not MainScreen.IsUpText(option) then
0 commit comments