SRL Archive - Research & Development Lounge

navigate and choose craft options


m34tcode

2012-04-14 02:23:48

This is what i am calling the craft menu: http://snpr.cm/tfvLB8.jpg

SRL currently has no function to choose options in there. This function currently works, but there is a single inefficiency I have yet to resolve. I will probably just use a variable tomorrow. Tired right now.

function SlideCraftMenu(Time : Integer; ToTheRight : Boolean) : Boolean;
var
Box : TBox;
BMP : Integer;
TP : TPoint;
begin
Result := False;
if ToTheRight then
begin
Box := IntToBox(493,394,505,462);
BMP := BitmapFromString(3, 5, 'meJyzC4zxi8sAIgNnfyufMN+Y1KDq' +
'Xj0HH++oJCBp4RUMZABJj7A4IAIASfsOPg==');
end else
begin
Box := IntToBox(12,394,24,463);
BMP := BitmapFromString(2, 5, 'meJwLSsq2C4xx8I80cPbXc/Cxj8u1' +
'9Q0DMryjkiy8ggGMfgjv');
end;
//exit func if we cant scroll
if FindBitmap(BMP,TP.x,TP.y) then
Exit;
MouseBox(Box.X1,Box.Y1,Box.X2,Box.Y2,mouse_move);
wait(Time);
GetMousePos(TP.x,TP.y);
MMouse(TP.x,TP.y-125,30,15);
//if we can still scroll further result = true
Result := not FindBitmap(BMP,TP.x,TP.y);
FreeBitmap(BMP);
end;


function ChooseCraftOption(OptionText : TStringArray) : Boolean;
var
MaxDuration : Integer;
T : LongInt;
begin
Result := False;
MaxDuration := RandomRange(10000,13000);
MarkTime(T);
while TimeFromMark(T) < MaxDuration do
begin
if FindTextTPAMulti(2070783,10,MCX1,MCY1,MCX2,MCY2,OptionText,StatChars,ClickLeft) then
begin
Result := True;
break;
end else if not SlideCraftMenu(RandomRange(1000,1300),True)
and not FindTextTPAMulti(2070783,10,MCX1,MCY1,MCX2,MCY2,OptionText,StatChars,ClickLeft) then
break;
end;
end;


Works admirably. Try it :biggrin:

Will also modify those search box coords so it is searching only the area the text will be in, instead of the whole chat area

AideniRS

2012-04-14 07:52:41

Shouldnt there be FreeBitmap in there? or would it be called somewhere else/not at all.

m34tcode

2012-04-14 10:23:20

You are correct. Cant believe I missed that D=

Fixed, thanks.

Imanoobbot

2012-04-14 12:01:02

Awesome! Thank you mate! ;)

m34tcode

2012-04-17 03:19:11

Wicked usefull, works perfectly, fit for the SRL Library?

Yago

2012-04-17 17:14:16

You could go for a crafting.simba Its more than just crafting though, its also smelting… many other things. I don't know if it would get in though

m34tcode

2012-04-17 17:54:31

Thats also a skills file, not actually included in srl.simba. This seems like it should be core, as it manipulates the runescape interface, and its a very general function

Joe

2012-04-17 18:02:46

From: m34tcode
Thats also a skills file, not actually included in srl.simba. This seems like it should be core, as it manipulates the runescape interface, and its a very general function


im with meat here. Its too broad of an interface to go into skills. and it manipulates the chatbox section… looks good meat! I usually just used DTMs in the chatbox to find this kind of stuff for cooking scripts, but this would speed things up a bit. Nice
Rep+

PatDuffy

2012-04-17 18:08:48

Just a heads up, with the urn crafter I just made, I had something similar until Kyle informed me of his function for dealing with these menu's.

function FindSelection(text: String): Boolean;
var
x, y : Integer;
begin
if FindTextTpaEx(2070783, 0, MCX1, MCY1, MCX2, MCY2, x, y, text, statchars, Nothing) then
begin
Mouse(x, y, 5, 5, mouse_Left);
Wait(RandomRange(150, 350));
Result := True;
end;
end;

Which works like so.

function DetermineUrn:Boolean;
var
F:Integer;
label Start;
begin
Start:
Result:=False;
Wait(1000);
While IsMoving do
Wait(100);
Wait(RandomRange(1500,2000));
if FindSelection('rns') then
Wait(RandomRange(1000,1500))
else
begin
Inc(F);
Writeln('Failed to find first menu option');
if(F>2) then
begin
F:=0;
Exit;
end;
goto Start;
end;
While IsMoving do
Wait(100);
case UrnSkill of
'Cooking','cooking','Fishing','fishing':
begin
MMouse(18,428,4,4);
Wait(RandomRange(1000,1500));
SetUp:=False;
case UrnSkill of
'Cooking','cooking':FindSelection('ook');
'Fishing','fishing':FindSelection('ish');
end;
end;
'Smithing','smithing','Woodcutting','woodcutting',
'Prayer','prayer','Mining','mining':
begin
if not SetUp then
begin
MMouse(500,429,4,4);
Wait(RandomRange(1500,1750));
end;
case UrnSkill of
'Mining','mining':FindSelection('inin');
'Smithing','smithing':FindSelection('melt');
'Woodcutting','woodcutting':FindSelection('ood');
'Prayer','prayer':FindSelection('ray');
end;
end;
end;
Wait(RandomRange(1000,1100));
if not SetUp then
begin
MMouse(500,429,4,4);
Wait(RandomRange(1500,1750));
SetUp:=True;
end;
case UrnType of
'Strong','strong':if FindSelection('tro') then
begin
Result:=True;
F:=0;
end;
'Decorated','decorated':if FindSelection('ecor') then
begin
Result:=True;
F:=0;
end;
end;
end;

punkd

2012-04-26 17:36:24

Pat, your method is probably the best way to go, I want to make a function of my own for my AIO

m34tcode

2012-04-27 00:16:24

That is near the same, but it does not choose options that are hidden. It also does not allow the user to find 'any' option. That will only work for urns

Kyle Undefined

2012-04-27 01:20:46

My method could be used for anything ;) I like your scrolling though :)

m34tcode

2012-04-27 01:28:12

Only anything that is visible ;]

This function will find any option, and click. I havent created the navigating function yet, but it shouldnt be hard. just accepts an array of string options, and strings for which craft menu is currently up.

Kyle Undefined

2012-04-27 01:49:53

Well duh, it's hard to see things that are hidden :p I thought yours had scrolling, all you'd have to do is search for the text, if it's not found, then scroll ;)

m34tcode

2012-04-27 01:52:52

right thats what it does. the scroll function will scroll in the specified direction, for the specified amount of time