Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions osrs/interfaces/mainscreen/goldscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ function TRSGoldScreen.CanCraftItem(Item: ERSGoldItem): Boolean;
```
Returns `True` if the given item icon is available for crafting.
*)
function TRSGoldScreen.CanCraftItem(i: ERSGoldItem): Boolean;
function TRSGoldScreen.CanCraftItem(i: ERSGoldItem): Boolean;
const
GOLD_COLOR: TColor := 2806763;
GOLD_COLOR : TColorTolerance := [$1FB2BC, 3.285, EColorSpace.LCH, [0.433, 0.512, 2.056]];
begin
if not Self.IsOpen() then
Exit;

Result := Target.FindColor(GOLD_COLOR, 1, Self.ItemBoxes[i]).Length > 0;
end;
Result := Target.HasColor(GOLD_COLOR, 10, Self.ItemBoxes[i]);
end;

(*
## GoldScreen.IsItemHighlighted
Expand All @@ -256,18 +256,18 @@ function TRSGoldScreen.IsItemHighlighted(Item: ERSGoldItem): Boolean;
```
Returns `True` if the given item is currently highlighted.
*)
function TRSGoldScreen.IsItemHighlighted(i: ERSGoldItem): Boolean;
function TRSGoldScreen.IsItemHighlighted(i: ERSGoldItem): Boolean;
var
highlight: TColorTolerance := [4807018,2];
goldColor : TColorTolerance := [$1FB2BC, 3.285, EColorSpace.LCH, [0.433, 0.512, 2.056]];
begin
if not Self.IsOpen() then
Exit;

if not Self.CanCraftItem(i) then
Exit;

Result := Target.FindColor(highlight, Self.ItemBoxes[i]).Length > 0;
end;
Result := Target.HasColor(goldColor, 10 ,Self.ItemBoxes[i]);
end;

(*
## GoldScreen.CraftItem
Expand All @@ -287,10 +287,13 @@ begin
if not Result then Exit;

if UseSpaceBar and Self.IsItemHighlighted(Item) then
Keyboard.KeyPress(EKeyCode.SPACE)
else
begin
Keyboard.KeyPress(EKeyCode.SPACE);
if not Self.IsOpen() then
Exit;
end;
Mouse.Click(Self.ItemBoxes[Item], EMouseButton.LEFT);
end;
end;

var
(*
Expand Down
7 changes: 5 additions & 2 deletions osrs/interfaces/mainscreen/silverscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ if SilverScreen.CanCraftItem('Opal ring', box) then
WriteLn 'Can craft opal ring';
```
*)
function TRSSilverScreen.CanCraftItem(Item : TRSItem; out Box : TBox) : Boolean;
function TRSSilverScreen.CanCraftItem(var Item : TRSItem; out Box : TBox) : Boolean;
const
READY_GOLD = $1F98FF; // gold text (craftable)
READY_WHITE = $FFFFFF; // white (selected/ready)
Expand All @@ -248,14 +248,17 @@ var
begin
if not Self.IsOpen() then Exit;

if Item.Contains('amulet' , False) then
Item := Item + ' (u)';

if not Self.Items.Find([Item], Slot) then
Exit;

Box := Self.ClickBoxes[Slot];

TPA := Target.FindColor(READY_GOLD, 1, Box) + Target.FindColor(READY_WHITE, 1, Box);
Result := TPA.Length > 0;
end;
end;


(*
Expand Down
Loading