SRL Archive - SRL Snippets

function UseItemWith(x,y,rx,ry,Slot:Integer; Uptext:String):Boolean;


Sin

2012-04-07 11:04:59


{*By: Sin.
Description: Uses item in selected slot with object in predefined variables
Last Modified: April 7th, 2012*}

function UseItemWith(x,y,rx,ry,Slot:Integer; Uptext:String):Boolean;
begin
if (x > 0) and (y > 0) and (Slot > 0) then
begin
MouseItem(Slot,0);
if OptionsExist(['Use','se'],False) then
begin
Result := True;
ChooseOption('Use');
Mouse(x,y,rx,ry,False);
WaitOption('-> ' + Uptext,1337);
end else exit;
end else exit;
if not Result then
begin
writeLn('Failed to find the Chooseoption');
exit;
end;
end;

Abu

2012-04-07 11:18:29

Hmmm, this would be useful I guess :)

Support

Sin

2012-04-07 11:19:18

It's just something I needed to use with my Altar script.
It seemed useful, worked 100% of the time.

masterBB

2012-04-07 11:30:20

There are also a few cons;
it's harder to implement failsafes.
It is exactly the same as(pseudocode):
function UseItemWith(args);
begin
MouseItem(Slot,0);
FindObjTPA(x,y,args); //or your own find function
Mouse(x,y,2,2,true);
end;
It doesn't let you implement other find object methods. You have to find the object, click the item then hope the object is still in the same place.

I'm a bit in a bad mood, will look at it later.

Sin

2012-04-07 11:32:49

Ah true that.
So wouldn't your suggestion working better?

Dayum, I was dealing with non moving objects, so I didn't think of that.

Kyle Undefined

2012-04-07 12:22:06

I'd rather see it use a MouseBox, but that's just me.

However, shouldn't it be up to the scripter to make these types of functions? Since you could do it many different ways?

Gu3st...

2012-04-07 12:47:53

Cleaned it up a bit

function UseItemMS(const X, Y, rX, rY : Integer; const Slot : Integer; const OptionText : String) : Boolean;
begin
Result := False;
if not LoggedIn then
Exit;
if (not InRange(X+rX, MSX1, MSX2)) or (not InRange(Y+rY, MSY1, MSY2)) or (not InRange(Slot, 0, 27)) then
Exit;

MouseItem(Slot, mouse_Right);
if OptionsExist(['Use', 'se'], False) then
begin
ChooseOption('Use');
Mouse(X, Y, rX, rY, False);
Result := WaitOption(OptionText, 1337);
end;
end;

masterBB

2012-04-08 08:43:58

From: Kyle Undefined
However, shouldn't it be up to the scripter to make these types of functions? Since you could do it many different ways?


I agree with Kyle on this one. It doesn't make sense to place this in the SRL include, especially in the current form.

There aren't that much applications for this either. Let's say you want to use iron ore on a furnace. You know the slot of the iron ore through a DTM check, the uptext still have to be checked as failsafe. The color of the furnace have to be found before you select the item. But what if your color function finds three group of point with your color, you need to hover them all to find the furnace. It doesn't make sense to call this function three times especially if it selects the item three times. You should add a failsafe to check if the item is already selected.

Coh3n

2012-04-08 22:25:44

Moved to snippets, and I agree that it should be left up to the scripter. It is a useful function, though. :)