SRL Archive - Reflection Development

R_ClickOption and R_MouseItemIDEx


Coh3n

2009-08-16 02:34:31

Hello, and welcome to my first every reflection suggestion thread! :D

The first function is R_ClickOption. For are more detailed description of this function please visit this thread -> ClickOption - My suggestion for Text.scar

{*******************************************************************************
function R_ClickOptionEx(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: TStringArray): Boolean;
By: Coh3n
Description: Will left click an object 9/10 times. Will right click an object
and choose the option accociated with ChooseOpt.
Valid arguments for Option: 'right', 'left', 'random'.
i.e R_ClickOption(x, y, 0, 0, 'random', ['Door'], ['Open']);
*******************************************************************************}
function R_ClickOptionEx(x, y, Rx, Ry: Integer; Option: String; UpText, ChooseOpt: TStringArray): Boolean;
begin
if not InStrArr(Option, ['random', 'right', 'left'], False) then Exit;
Result := WaitUpTextMulti(UpText, 100 + Random(400));
if not Result then Exit;
if Option = 'random' then
if Random(10) = 1 then
Option := 'right'
else
Option := 'left';
Mouse(x, y, rx, ry, Option = 'left');
if Option = 'right' then
R_ChooseActionMulti(ChooseOpt);
Wait(1000 + Random(500));
end;

{*******************************************************************************
function R_ClickOption(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: String): Boolean;
By: Coh3n
Description: Works like R_ClickOptionEx, but uses Strings instead of TStingArray.
*******************************************************************************}

function R_ClickOption(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: String): Boolean;
begin
Result := R_ClickOptionEx(x, y, rx, ry, Option, [UpText], [ChooseOpt]);
end;
My second suggestion is just a small change to lordsaturn's function R_MouseItemID. His function always right clicks an object, then chooses the option. I just modified it slightly, so it will left click the item. :)
{*******************************************************************************
function R_MouseItemIDEx(ID: Integer; Option: String): Boolean;
By: R_MouseItemID by lordsaturn, modified by Coh3n
Description: Left clicks an item with the given ID.
*******************************************************************************}
function R_MouseItemIDEx(ID: Integer): Boolean;
var
Inv, x, y, ItemID, i : Integer;
B : TBox;
begin
Inv := GetInterface(149, 0);
Result := False;
for i := 0 to 27 do
begin
ItemID := SmartGetFieldArrayInt(Inv, InventoryItemIDs, i);
if (ItemID > 0) and (ItemID = ID) then
begin
Wait(80 + Random(100));
Mouse(x, y, 0, 0, True);
Break;
end;
end;
SmartFreeObject(Inv);
end;
Well, that's all I have for now, thanks for reading. Please post suggestions/comments.

Thanks. :)

Smarter Child

2009-08-17 00:14:49

Good Job, if it was in the include I'd use ;).

Coh3n

2009-08-17 00:17:21

From: Smarter Child
Good Job, if it was in the include I'd use ;).


Hey thanks a lot. :D I'm glad you like it.

Sabzi

2009-08-17 00:30:25

I got something that I don't understand. I write my feelings down as comments.
function R_MouseItemIDEx(ID: Integer; Option: String): Boolean;  //for just clicking why do we still got an option?
var
Inv, x, y, ItemID, i : Integer;
B : TBox;
begin
Inv := GetInterface(149, 0);
Result := False;
for i := 0 to 27 do
begin
ItemID := SmartGetFieldArrayInt(Inv, InventoryItemIDs, i);
if (ItemID > 0) and (ItemID = ID) then
begin
B := InvBox(i + 1);
MouseBox(B.x1, B.y1, B.x2, B.y2, 2); //this will right click the item
Wait(80 + Random(100));
Mouse(x, y, 0, 0, True); //an option menu is up and we click the x, y coordinates, but where x and y are from?
Break;
end;
end;
SmartFreeObject(Inv);
end;

Coh3n

2009-08-17 00:34:03

From: Sabzi
I got something that I don't understand. I write my feelings down as comments.


:duh: Sabzi I <3 you. I never actually got a chance to test that function, it was something I quickly made to add into my script, and obviously I overlooked those elements. Changing them right away.

I can't believe I overlooked that. :duh:

EDIT: I still don't know if that's exactly right, but I plan on testing it out ASAP.

Sabzi

2009-08-17 00:37:03

From: Coh3n
:duh: Sabzi I <3 you. I never actually got a chance to test that function, it was something I quickly made to add into my script, and obviously I overlooked those elements. Changing them right away.

I can't believe I overlooked that. :duh:


Haha I am just paying back your help. And I am glad that I could help. It seems that we can't find our own mistakes but we can find others :D

EDIT:
How I would fix that previous thing:
procedure R_MouseItemIDEx(ID: Integer);
var
Inv, ItemID, i : Integer;
B : TBox;
begin
Inv := GetInterface(149, 0);
for i := 0 to 27 do
begin
ItemID := SmartGetFieldArrayInt(Inv, InventoryItemIDs, i);
if (ItemID > 0) and (ItemID = ID) then
begin
B := InvBox(i + 1);
MouseBox(B.x1, B.y1, B.x2, B.y2, 1);
Wait(80 + Random(100));
Break;
end;
end;
SmartFreeObject(Inv);
end;

I have changed it to a procedure because I couldn't find any line that actually sets Result to True.

Coh3n

2009-08-17 00:38:02

From: Sabzi
Haha I am just paying back your help. And I am glad that I could help. It seems that we can't find our own mistakes but we can find others :D


Haha well that's why we have such a great community with people that point out all those silly errors. :p

Nava2

2009-08-17 07:15:14

Ah, the beautiful aspects of open source.

Coh3n

2009-08-27 19:17:56

From: Nava2
Ah, the beautiful aspects of open source.


Haha! :D