SRL Archive - SRL Archives

Inventory.scar DropItem();


NCDS

2010-02-10 23:09:21

Just shortened it up a bit…

Old version:

{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}
function DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
if (WaitOptionEx('rop', 'action', ClickLeft, 250)) then
begin
Result := True;
Wait(RandomRange(50, 200));
end;
end;
end;
My version:

{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}
function N_DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
Result := (WaitOptionEx('rop', 'action', ClickLeft, 250));
end;
end;

Blumblebee

2010-02-11 00:07:14

meh sometimes readability isn't such a bad thing. Unless the speed is a huge increase in your fix I don't really see the point :/ It just complicates things and people can't understand it anymore (unless you go and read WaitOptionEx which is time consuming for the lazy :p)

none the less, nice :)

NCDS

2010-02-11 13:08:11

No this really doesn't effect much. I've just been going through the include more lately fixing up what I can.

marpis

2010-02-16 09:35:47

You only took the random wait away which I don't think is a good idea?

void_hatred

2010-02-16 10:09:53

I agree with marpis,

fair enough when something is like..


if a then
begin
Result := true;
end else
begin
Result := false;
end;

then It'd be much better to simply do..


Result := a;

however, the if clause contained 2 expressions, Result assignment and Random wait, so.. while it is a shortened version, it doesn't work the same.

…and if you were to just "add it on", like…


{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}
function N_DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
Result := (WaitOptionEx('rop', 'action', ClickLeft, 250));
Wait(RandomRange(50, 200));
end;
end;

then it'd wait if WaitOptionEx was true/false, not just true like in the original code

void_hatred

NCDS

2010-02-16 11:34:48

Personally in my scripts I take care of random waits and what not on my own so I just didn't think about a wait after the function being necessary. I see where you both are coming from though.

marpis

2010-02-18 00:18:38

From: NCDS
Personally in my scripts I take care of random waits and what not on my own so I just didn't think about a wait after the function being necessary. I see where you both are coming from though.

Most people drop like

for i := n to 28 do
DropItem(i);
Also DropAllExcept, DropAll call DropItem without waiting after it.